Struct self_reference::SelfReference
source · [−]pub struct SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,{ /* private fields */ }
Expand description
A Self-Referential Helper.
Implementations
sourceimpl<'a, T, R> SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
impl<'a, T, R> SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
sourcepub fn new<F>(object: T, init: F) -> Selfwhere
F: FnOnce() -> <R as RefDef<'static>>::Type,
pub fn new<F>(object: T, init: F) -> Selfwhere
F: FnOnce() -> <R as RefDef<'static>>::Type,
You will “never” able to hold object before its pinned. try initializing as empty static object. (using Option, NonNull or Empty enum field)
pub fn new_stable<F>(object: T, init: F) -> Selfwhere
T: StableDeref + DerefMut,
F: FnOnce(&mut T::Target) -> <R as RefDef<'_>>::Type,
sourcepub fn reset<'s, F>(self: Pin<&'s mut Self>, f: F)where
F: FnOnce(Pin<&'s mut T>) -> <R as RefDef<'s>>::Type,
pub fn reset<'s, F>(self: Pin<&'s mut Self>, f: F)where
F: FnOnce(Pin<&'s mut T>) -> <R as RefDef<'s>>::Type,
reset referenceial object using object. object is now pinned so initializing referential type is safe. This is also useful when you consumed your own reference. (like in AsyncIterator)
sourceimpl<'a, T, R> SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
for<'this> <R as RefDef<'this>>::Type: Unpin,
impl<'a, T, R> SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
for<'this> <R as RefDef<'this>>::Type: Unpin,
sourceimpl<'a, T, R> SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
T: Unpin,
impl<'a, T, R> SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
T: Unpin,
sourcepub fn reset_unpin<'s, F>(self: Pin<&'s mut Self>, f: F)where
F: FnOnce(&'s mut T) -> <R as RefDef<'s>>::Type,
pub fn reset_unpin<'s, F>(self: Pin<&'s mut Self>, f: F)where
F: FnOnce(&'s mut T) -> <R as RefDef<'s>>::Type,
reset referenceial object using unpinned object. object is now pinned so initializing referential type is safe. This is also useful when you consumed your own reference. (like in AsyncIterator)
Trait Implementations
impl<'pin, 'a, T, R> Unpin for SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
Wrapper<'pin, Self>: UnsafeUnpin,
impl<'a, T, R> UnsafeUnpin for SelfReference<'a, T, R>where
for<'this> R: RefDef<'this>,
for<'this> <R as RefDef<'this>>::Type: 'a,
T: StableDeref,
Auto Trait Implementations
impl<'a, T, R> RefUnwindSafe for SelfReference<'a, T, R>where
T: RefUnwindSafe,
<R as RefDef<'a>>::Type: RefUnwindSafe,
impl<'a, T, R> Send for SelfReference<'a, T, R>where
T: Send,
<R as RefDef<'a>>::Type: Send,
impl<'a, T, R> Sync for SelfReference<'a, T, R>where
T: Sync,
<R as RefDef<'a>>::Type: Sync,
impl<'a, T, R> UnwindSafe for SelfReference<'a, T, R>where
T: UnwindSafe,
<R as RefDef<'a>>::Type: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more