Simple error while implementing Borrow for my Wrapper type
The Rust Programming Language Forum
Simple error while implementing Borrow for my Wrapper type
hi folks! struct Wrapper(String); impl Borrow<str> for Wrapper { fn borrow(&self) -> &str { &*self.0.as_str() } } below why does one have to return a borrow with lifetime 'a (confused because we nowhere annotate this in the signature)? Is it because of the implicit bound: 'a: '1 that the compiler just wants us to return something that lives at least as long as 'a? impl<'a> Borrow<&'a str> for Wrapper { // &'1 &'1 // v v fn borrow(&self)...
0 comments
No comments yet.