Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect lifetime in Value::to_str() #587

Merged
merged 1 commit into from Oct 9, 2023

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.

@KodrAus KodrAus merged commit bc5ca09 into rust-lang:master Oct 9, 2023
14 checks passed
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.

None yet

3 participants