You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's an actual difference between fn get_str<'a>() -> &'a str; and fn get_str() -> &'static str;. There wasn't until rust-lang/rust#42417 got merged, but since then <'a> will work in some cases where a simple 'static will not.
The text was updated successfully, but these errors were encountered:
Wow, nice find. I'll fix the "pointlessly generic" comment to say something else, but I'm wondering if this warrants its own section in the article.
Almost everyone, myself included, thinks "I can use a 'static ref where an 'a ref is expected"... but that is surprisingly not true in all cases. To import the example from the issue you linked:
I'll think over how I wanna introduce this information into the article, and what amendments I might have to make. Thanks for bringing this to my attention!
There's an actual difference between
fn get_str<'a>() -> &'a str;
andfn get_str() -> &'static str;
. There wasn't until rust-lang/rust#42417 got merged, but since then<'a>
will work in some cases where a simple'static
will not.The text was updated successfully, but these errors were encountered: