pub struct RefContainer<'r, T>(/* private fields */);Expand description
Container implementation via exclusive reference to MaybeUninit
Implements ExclusiveContainer
§Example
let mut tmp = MaybeUninit::uninit();
let mut container = RefContainer::init_value(&mut tmp, 42);
let shared: &i32 = &container;
let exclusive: Pin<&mut i32> = container.inner();
let mut tmp = MaybeUninit::uninit();
let container2 = container.mv::<RefContainer<_>>(&mut tmp);Note that this container has a non-() allocator, and you might want to explicitly allocate MaybeUninit:
let mut tmp = MaybeUninit::uninit();
let container = RefContainer::init_value(&mut tmp, 42);This works just fine too, although a bit verbose
Implementations§
Source§impl<'r, T> RefContainer<'r, T>
impl<'r, T> RefContainer<'r, T>
Sourcepub fn iter<'r0>(&'r0 self) -> <&'r0 Self as IntoIterator>::IntoIterwhere
for<'r1> &'r1 T: IntoIterator,
'r: 'r0,
pub fn iter<'r0>(&'r0 self) -> <&'r0 Self as IntoIterator>::IntoIterwhere
for<'r1> &'r1 T: IntoIterator,
'r: 'r0,
Same as <&Self as IntoIterator>::into_iter(self)
Trait Implementations§
Source§impl<'r, T> AsRef<<RefContainer<'r, T> as Container>::Inner> for RefContainer<'r, T>
impl<'r, T> AsRef<<RefContainer<'r, T> as Container>::Inner> for RefContainer<'r, T>
Source§impl<'r, T> Container for RefContainer<'r, T>
impl<'r, T> Container for RefContainer<'r, T>
Source§type Allocator = &'r mut MaybeUninit<T>
type Allocator = &'r mut MaybeUninit<T>
Type used to create uninitialized version of the container Read more
Source§type Uninit = UninitRefContainer<'r, T>
type Uninit = UninitRefContainer<'r, T>
Container in the uninitialized state. Usually somewhat similar to container itself Read more
Source§fn uninit(allocator: Self::Allocator) -> Self::Uninit
fn uninit(allocator: Self::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<'r, T: Debug> Debug for RefContainer<'r, T>
impl<'r, T: Debug> Debug for RefContainer<'r, T>
Source§impl<T> Deref for RefContainer<'_, T>
impl<T> Deref for RefContainer<'_, T>
Source§impl<T: Display> Display for RefContainer<'_, T>
impl<T: Display> Display for RefContainer<'_, T>
Source§impl<T> Drop for RefContainer<'_, T>
impl<T> Drop for RefContainer<'_, T>
Source§impl<T> ExclusiveContainer for RefContainer<'_, T>
impl<T> ExclusiveContainer for RefContainer<'_, T>
Source§fn inner(&mut self) -> Pin<&mut Self::Inner>
fn inner(&mut self) -> Pin<&mut Self::Inner>
Gets exclusive reference to inner value. Note that exclusive reference is always pinned
Source§impl<'r0, 'r, T> IntoIterator for &'r0 RefContainer<'r, T>where
for<'r1> &'r1 T: IntoIterator,
'r: 'r0,
impl<'r0, 'r, T> IntoIterator for &'r0 RefContainer<'r, T>where
for<'r1> &'r1 T: IntoIterator,
'r: 'r0,
Auto Trait Implementations§
impl<'r, T> Freeze for RefContainer<'r, T>
impl<'r, T> RefUnwindSafe for RefContainer<'r, T>where
T: RefUnwindSafe,
impl<'r, T> Send for RefContainer<'r, T>where
T: Send,
impl<'r, T> Sync for RefContainer<'r, T>where
T: Sync,
impl<'r, T> Unpin for RefContainer<'r, T>
impl<'r, T> !UnwindSafe for RefContainer<'r, T>
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