Why can lifetime arguments be omitted when explicitly specifying arguments in turbofish?

⚓ Rust    📅 2025-10-10    👤 surdeus    👁️ 3      

surdeus

fn foo<'a,T>(){
    
}
fn main() {
  foo::<i32>();
}

The first generic parameter is a lifetime parameter; however, in the call site, only the type parameter is specified, which does not correspond to the lifetime parameter, and the specified type argument doesn't match the lifetime parameter. Paths - The Rust Reference says:

The order of generic arguments is restricted to lifetime arguments, then type arguments, then const arguments, then equality constraints.

So, why is this code ok?

2 posts - 2 participants

Read full topic

🏷️ Rust_feed