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 Mutex::into_inner method #2250

Merged
merged 1 commit into from
Feb 17, 2020
Merged

Add Mutex::into_inner method #2250

merged 1 commit into from
Feb 17, 2020

Conversation

WaffleLapkin
Copy link
Contributor

Add Mutex::into_inner method that consumes mutex
and return underlying value.

I'm not sure what to test here, so I didn't add any tests.

Fixes #2211

Motivation

There are cases when you need to get ownership over the underlying value.

Also, both std::sync::Mutex and futures::sync::Mutex have the methods into_inner that allow you to consume the mutex and get the owned value from it.

Solution

Add into_inner method for sync::Mutex that simply calls into_inner on inner UnsafeCell

Add `Mutex::into_inner` method that consumes mutex
and return underlying value.

Fixes: #2211
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine 👍 thanks!

@LucioFranco LucioFranco merged commit 09b5f47 into tokio-rs:master Feb 17, 2020
@WaffleLapkin WaffleLapkin deleted the mutex_into_inner branch February 17, 2020 16:57
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.

Implement into_inner for sync::Mutex
2 participants