Function where output lifetime has no relation to inputs?
⚓ Rust 📅 2025-07-07 👤 surdeus 👁️ 19I'm reading the lifetime misconceptions article, and it has this example:
// no relationship between input & output lifetimes
fn overlap<'a>(s: &str, t: &str) -> &'a str;
// expands to:
fn overlap<'a, 'b, 'c>(s: &'a str, t: &'b str) -> &'c str;
I wonder how I would write or use such a function. If the output lifetime is not 'static and not determined by the inputs, where would it be coming from? Can someone give an example situation that uses such a function?
5 posts - 5 participants
🏷️ rust_feed