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

Add Cow::make_mut #22

Merged
merged 4 commits into from
Aug 7, 2023
Merged

Add Cow::make_mut #22

merged 4 commits into from
Aug 7, 2023

Conversation

michaelsproul
Copy link
Member

@michaelsproul michaelsproul commented Aug 7, 2023

It is useful to be able to upgrade a Cow pointer into its mutable variant without consuming it, which is what Cow::to_mut does. This PR adds a new method Cow::make_mut which makes the Cow pointer mutable, and returns it. The returned reference has a shorter lifetime than the one returned by to_mut because it borrows from &mut self rather than self.

The to_mut method has been renamed into_mut as we needed to change its type signature anyway to introduce a Result type. The new make_mut also returns a Result.

@michaelsproul michaelsproul merged commit d106d79 into main Aug 7, 2023
5 checks passed
@michaelsproul michaelsproul deleted the cow-make-mut branch August 7, 2023 23:56
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.

1 participant