Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Function where output lifetime has no relation to inputs?
I'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