Skip to content

Conversation

peterjoel
Copy link
Contributor

Without this change, the following code will not compile:

let foo = record
    .key_values()
    .get(Key::from_str("foo"))
    .and_then(|val| val.to_str());

with the following error:

   |
32 |         .and_then(|val| val.to_str());
   |                         ^^^^^^^^^^^^ returns a reference to data owned by the current function

@Thomasdezeeuw
Copy link
Collaborator

Not really an incorrect lifetime though, the change introduces a broader/larger lifetime.

@peterjoel
Copy link
Contributor Author

Thanks for the fast response!

And yes, incorrect was perhaps a little opinionated! What I meant was: shorter than necessary and likely unintentionally so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants