Type Definition hybrid_rc::Arc[][src]

pub type Arc<T> = HybridRc<T, Shared>;
Expand description

Type alias for a shared reference counting pointer.

Provided to ease migrating from std::sync::Arc.

See the module-level documentation for more details.

The inherent methods of Arc are all associated functions, which means that you have to call them as e.g. Arc::to_local(&x) instead of x.to_local(). This avoids conflicts with methods of the inner type T.

Implementations

Creates a new local reference (Rc) for the referenced value.

Returns None if at least one Rc already exists on another thread.

Note: In no_std environments None is returned if at least one Rc exists on any thread.

Example
use hybrid_rc::{Rc, Arc};

let local = Rc::new(42i32);
let shared = Rc::to_shared(&local);

// `shared` can be safely transferred to another thread
std::thread::spawn(move || assert_eq!(*shared, 42i32)).join()?;