3 ms·
pub fn search<'searching>(query: &str, contents: &'searching str) -> Vec<&'searching str> { vec![] } Give your lifetimes meaningful names.
by anticensor 7y ago
pub fn search<'searching>(query: &str, contents: &'searching str) -> Vec<&'searching str> {
vec![]
}
Give your lifetimes meaningful names.
- empath75 7y agoThat’s interesting — I haven’t seen any code that does this. Do you have more fleshed out examples on github to share?
- steveklabnik 7y agoWe had discussions about this prior to 1.0, and some people do write code this way, but in general, you’re only using lifetimes in more complex code, and doing this makes it even more verbose. It does sometimes help, though. I personally prefer the ‘a version in this case for this reason, it’s actually harder for me to understand. YMMV.