Cannot return value referencing temporary value while lifetime should be valid
The Rust Programming Language Forum
Cannot return value referencing temporary value while lifetime should be valid
Hi everyone, I have a case I am not sure why it is not valid, here is a small recreation of the issue in playground here is the code of the playground trait Foo { fn foo(&self) -> &'_ str; } struct MyType<'a>(&'a str); impl<'a> Foo for MyType<'a> { fn foo(&self) -> &'a str { self.0 } } fn main() { let s: Vec<_> = "hello world" .to_string() .split_whitespace() .map(String::from) .collect(); let new: Vec<&str> = s.iter().map(|s| M...
0 comments
No comments yet.