How to take ownership T out of Arc<T>?

I know how to take ownership out of a Box:

    let unique = Box::new(Foo {});
    let foo = *unique;

And I know how to get a mutable reference from an Arc:

    let mut shared = Arc::new(Foo{});
    let foo = Arc::get_mut(&mut shared).unwrap();

But can I take the ownership out of an Arc?

1 Like

A quick docs search reveals try_unwrap().


Thanks, I tried some keywords like take, or own, didn't expect it to be unwrap.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.