What's the semantic difference between `use<'a>` and `+'a` in the returned opaque type place

⚓ Rust    📅 2026-06-30    👤 surdeus    👁️ 3      

surdeus

Consider this example:

fn show<'a>(i:&'a i32)->impl Future + 'a { 
   async {}
}

fn show2<'a>(I:&'a i32)->impl Future + use<'a>{
   async {}
}

In show, saying the returned concrete type is T, the syntax +'a means T:'a. However, I still cannot completely understand what use<'a> exactly means in show2. IIUC, the first effect is to explicitly specify that T captures the lifetime 'a as if it behaved as T<'a>. Under this concept, T<'a>:'a still holds. So, what's the difference between use<'a> and +'a for another purpose?

1 post - 1 participant

Read full topic

🏷️ Rust_feed