Skip to content

Add Mutex::into_inner() #1269

Closed
Closed
@tomaka

Description

@tomaka
impl<T> Mutex<T> {
    pub fn into_inner(self) -> T {
         ...
    }
}

This is very useful for structures like this:

struct Foo {
     data: Mutex<Bar>
}

impl Foo {
    fn modify(&self) {
        self.data.lock().unwrap().modify();
    }

    fn consume(self) {
        let bar = self.data.into_inner();    // oops! doesn't exist
        bar.consume();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions