Inferring lifetimes in simple cases


#1

I’m trying to understand what issues there are with the compiler inferring lifetimes in simple “single type” cases like this (instead of spitting out “missing lifetime specifier”):

fn my_fn<T>(items: T) where T: Iterator<&str> {
    println!("hello")
}

I’m just not sure why the lifetime needs to be explicitly stated and it can’t be inferred? If the user wants an unusual lifetime like 'static then they can declare it explicitly (analogous to how one does for mutable variables)

I raised this issue here a while back, but the discussion didn’t get very far: