Struct lazy_pinned::LazyPinned
source · pub struct LazyPinned<T>(pub Option<T>);
Expand description
Pinned data which can be lazily initialized.
LazyPinned<T>
vs. Option<T>
LazyPinned<T>
act like Option<T>
.
In fact, LazyPinned<T>
is implemented by just wrapping Option<T>
.
However, they have different behaviors in pinning projection.
Pin<P<Option<T>>>
guarantees the Option<T>
is not moved,
where P<_>
is a pointer type which deref to _
.
Thus, when the data is None
, it cannot be set to Some(T)
unless
T: Unpin
.
Pin<P<LazyPinned<T>>>
only guarantees the inner T
is pinned.
Thus, Pin<&mut LazyPinned<T>>
optionally projects to Pin<&mut T>
instead of Pin<P<Option<T>>>
. When Pin<P<LazyPinned<T>>>
is None
,
it can be initialized with a value of T
.
Tuple Fields§
§0: Option<T>
Implementations§
source§impl<T> LazyPinned<T>
impl<T> LazyPinned<T>
pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>>
pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>>
pub fn pin_project_or_insert(self: Pin<&mut Self>, v: T) -> Pin<&mut T>
pub fn pin_project_or_insert_with( self: Pin<&mut Self>, f: impl FnOnce() -> T ) -> Pin<&mut T>
pub fn use_pin_or_insert( self: Pin<&mut Self>, use_pin: impl FnOnce(Pin<&mut T>), v: T ) -> Pin<&mut T>
pub fn use_pin_or_insert_with( self: Pin<&mut Self>, use_pin: impl FnOnce(Pin<&mut T>), insert: impl FnOnce() -> T ) -> Pin<&mut T>
pub fn use_pin_or_insert_with_data<Data>( self: Pin<&mut Self>, data: Data, use_pin: impl FnOnce(Data, Pin<&mut T>), insert: impl FnOnce(Data) -> T ) -> Pin<&mut T>
Trait Implementations§
source§impl<T: Clone> Clone for LazyPinned<T>
impl<T: Clone> Clone for LazyPinned<T>
source§fn clone(&self) -> LazyPinned<T>
fn clone(&self) -> LazyPinned<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for LazyPinned<T>
impl<T: Debug> Debug for LazyPinned<T>
source§impl<T> Default for LazyPinned<T>
impl<T> Default for LazyPinned<T>
source§impl<T: Hash> Hash for LazyPinned<T>
impl<T: Hash> Hash for LazyPinned<T>
source§impl<T: Ord> Ord for LazyPinned<T>
impl<T: Ord> Ord for LazyPinned<T>
source§fn cmp(&self, other: &LazyPinned<T>) -> Ordering
fn cmp(&self, other: &LazyPinned<T>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialEq> PartialEq<LazyPinned<T>> for LazyPinned<T>
impl<T: PartialEq> PartialEq<LazyPinned<T>> for LazyPinned<T>
source§fn eq(&self, other: &LazyPinned<T>) -> bool
fn eq(&self, other: &LazyPinned<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd> PartialOrd<LazyPinned<T>> for LazyPinned<T>
impl<T: PartialOrd> PartialOrd<LazyPinned<T>> for LazyPinned<T>
source§fn partial_cmp(&self, other: &LazyPinned<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &LazyPinned<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more