pub struct VRcMapped<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> { /* private fields */ }
Expand description
VRcMapped allows bundling a VRc of a type along with a reference to an object that’s
reachable through the data the VRc owns and that satisfies the requirements of a Pin.
VRCMapped is constructed using VRc::map
and, like VRc, has a weak counterpart, VWeakMapped
.
Implementations
sourceimpl<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> VRcMapped<VTable, MappedType>
impl<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> VRcMapped<VTable, MappedType>
sourcepub fn downgrade(this: &Self) -> VWeakMapped<VTable, MappedType>
pub fn downgrade(this: &Self) -> VWeakMapped<VTable, MappedType>
Returns a new VWeakMapped
that points to this instance and can be upgraded back to
a Self
as long as a VRc
/VMapped
exists.
sourcepub fn as_pin_ref(&self) -> Pin<&MappedType>
pub fn as_pin_ref(&self) -> Pin<&MappedType>
Create a Pinned reference to the mapped type.
This is safe because the map function returns a pinned reference.
sourcepub fn map<ReMappedType: ?Sized>(
this: Self,
map_fn: impl for<'r> FnOnce(Pin<&'r MappedType>) -> Pin<&'r ReMappedType>
) -> VRcMapped<VTable, ReMappedType>
pub fn map<ReMappedType: ?Sized>(
this: Self,
map_fn: impl for<'r> FnOnce(Pin<&'r MappedType>) -> Pin<&'r ReMappedType>
) -> VRcMapped<VTable, ReMappedType>
This function allows safely holding a reference to a field inside the VRcMapped
. In order to accomplish
that, you need to provide a mapping function map_fn
in which you need to provide and return a
pinned reference to the object you would like to map. The returned VRcMapped
allows obtaining
that pinned reference again using VRcMapped::as_pin_ref
.
See also VRc::map
Trait Implementations
sourceimpl<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> Clone for VRcMapped<VTable, MappedType>
impl<VTable: VTableMetaDropInPlace + 'static, MappedType: ?Sized> Clone for VRcMapped<VTable, MappedType>
Auto Trait Implementations
impl<VTable, MappedType: ?Sized> RefUnwindSafe for VRcMapped<VTable, MappedType> where
MappedType: RefUnwindSafe,
<VTable as VTableMeta>::VTable: RefUnwindSafe,
impl<VTable, MappedType> !Send for VRcMapped<VTable, MappedType>
impl<VTable, MappedType> !Sync for VRcMapped<VTable, MappedType>
impl<VTable, MappedType: ?Sized> Unpin for VRcMapped<VTable, MappedType>
impl<VTable, MappedType: ?Sized> UnwindSafe for VRcMapped<VTable, MappedType> where
MappedType: RefUnwindSafe,
<VTable as VTableMeta>::VTable: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more