pub struct ArcContainer<T>(/* private fields */);Available on crate feature
alloc only.Expand description
Container implementation via privately implemented Arc
§Example
let mut container = ArcContainer::init_value((), 42);
let shared: &i32 = &container;
let exclusive: Pin<&mut i32> = container.try_inner().expect("Single Arc should have exclusive access");
let mut container2 = container.try_mv::<ArcContainer<_>>(()).expect("Single Arc should be always successfully moved out of");
let container3 = container2.clone(); // container is not longer exclusive
assert!(container2.try_inner().is_none(), "Non-excluive Arc should not be able to get &mut");
let shared: &i32 = &container2; // shared reference is still ok
assert!(container2.try_mv::<ArcContainer<_>>(()).is_none());Implementations§
Source§impl<T> ArcContainer<T>
impl<T> ArcContainer<T>
Sourcepub fn iter<'r0>(&'r0 self) -> <&'r0 Self as IntoIterator>::IntoIterwhere
for<'r1> &'r1 T: IntoIterator,
pub fn iter<'r0>(&'r0 self) -> <&'r0 Self as IntoIterator>::IntoIterwhere
for<'r1> &'r1 T: IntoIterator,
Same as <&Self as IntoIterator>::into_iter(self)
Trait Implementations§
Source§impl<T> AsRef<<ArcContainer<T> as Container>::Inner> for ArcContainer<T>
impl<T> AsRef<<ArcContainer<T> as Container>::Inner> for ArcContainer<T>
Source§impl<T> Clone for ArcContainer<T>
impl<T> Clone for ArcContainer<T>
Source§impl<T> Container for ArcContainer<T>
impl<T> Container for ArcContainer<T>
Source§type Uninit = UninitArcContainer<T>
type Uninit = UninitArcContainer<T>
Container in the uninitialized state. Usually somewhat similar to container itself Read more
Source§fn uninit(_allocator: ()) -> Self::Uninit
fn uninit(_allocator: ()) -> Self::Uninit
Creates container in the uninitialized state Read more
Source§fn uninit_inner_ptr(uninit: &mut Self::Uninit) -> *mut Self::Inner
fn uninit_inner_ptr(uninit: &mut Self::Uninit) -> *mut Self::Inner
Retrieves pointer to the contents of uninit container
Source§fn try_inner(&mut self) -> Option<Pin<&mut Self::Inner>>
fn try_inner(&mut self) -> Option<Pin<&mut Self::Inner>>
Gets exclusive reference to inner value. Note that exclusive reference is always pinned Read more
Source§fn try_move_out<O>(
self,
action: impl FnOnce(*mut Self::Inner) -> O,
) -> Option<O>
fn try_move_out<O>( self, action: impl FnOnce(*mut Self::Inner) -> O, ) -> Option<O>
Moves value out of the container.
action is called at most once (i.e. 1 or 0 times) and provided with a pointer to contained value (i.e. it is valid for reads and points to valid Container::Inner) Read moreSource§unsafe fn init_ptr(
allocator: Self::Allocator,
initializer: impl FnOnce(*mut Self::Inner),
) -> Self
unsafe fn init_ptr( allocator: Self::Allocator, initializer: impl FnOnce(*mut Self::Inner), ) -> Self
Provided helper function creating and initializing the container in a single call Read more
Source§impl<T: Debug> Debug for ArcContainer<T>
impl<T: Debug> Debug for ArcContainer<T>
Source§impl<T> Deref for ArcContainer<T>
impl<T> Deref for ArcContainer<T>
Source§impl<T: Display> Display for ArcContainer<T>
impl<T: Display> Display for ArcContainer<T>
Source§impl<'r0, T> IntoIterator for &'r0 ArcContainer<T>where
for<'r1> &'r1 T: IntoIterator,
impl<'r0, T> IntoIterator for &'r0 ArcContainer<T>where
for<'r1> &'r1 T: IntoIterator,
Auto Trait Implementations§
impl<T> Freeze for ArcContainer<T>
impl<T> RefUnwindSafe for ArcContainer<T>where
T: RefUnwindSafe,
impl<T> Send for ArcContainer<T>
impl<T> Sync for ArcContainer<T>
impl<T> Unpin for ArcContainer<T>
impl<T> UnwindSafe for ArcContainer<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<S> AddNuclideSpec for S
impl<S> AddNuclideSpec for S
fn add_nuclide(&self, mixture: Pin<&mut NuclideMixture<'_>>)
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more