Advanced
Rust
Q62 / 100
What is the Higher-Ranked Trait Bound (HRTB) for<'a>?
Correct! Well done.
Incorrect.
The correct answer is B) A bound meaning the trait must hold for all possible lifetimes: where F: for<'a> Fn(&'a str) -> &'a str
B
Correct Answer
A bound meaning the trait must hold for all possible lifetimes: where F: for<'a> Fn(&'a str) -> &'a str
Explanation
HRTB are needed when a closure must work with any lifetime. fn apply<F: for<'a> Fn(&'a i32) -> &'a i32>(f: F) expresses that F is valid for any concrete lifetime 'a.
Progress
62/100