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().

5 Likes

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