Higher ranked lifetime in multiple where clauses
⚓ Rust 📅 2025-12-13 👤 surdeus 👁️ 1I'm in a situation where I try to define a function looking like this :
fn foo<N>(f: impl for<'a> Fn(&'a N, &'a [u32]) -> (impl Iterator<Item = N> + 'a)) { /* ... */ }
This code generate the following error :
error[E0562]: `impl Trait` is not allowed in the return type of `Fn` trait bounds
I want to express the fact the returned value of f depends on the lifetime 'a but I don't know who to write this with where close.
Something like this :
fn foo<N, FN, IN>(f: FN)
where
FN: for<'a> Fn(&'a N, &'a [u32]) -> (IN + 'a),
IN: Iterator<Item = N>,
{/* ... */}
Do you have any solution ?
4 posts - 3 participants
🏷️ Rust_feed