pub struct DynDynFat<B: ?Sized + DynDynBase, P> { /* private fields */ }Expand description
A fat pointer to an object that can be downcast via the base trait object B.
Such a pointer will only perform a call to retrieve the DynDynTable of the referenced object once when created. Thereafter, the
cached table will be used for trait object metadata lookups. This effectively avoids the overhead of the repeated indirect calls to
retrieve the table at the cost of increasing the size of the pointer to the object.
Implementations§
Source§impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B>> DynDynFat<B, P>
impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B>> DynDynFat<B, P>
Sourcepub unsafe fn new_unchecked(ptr: P, table: DynDynTable) -> Self
pub unsafe fn new_unchecked(ptr: P, table: DynDynTable) -> Self
Creates a new fat pointer with the provided pointer and DynDynTable.
§Safety
table must refer to the same table as a table that would be returned by calling GetDynDynTable::get_dyn_dyn_table on ptr at
the time that this function is called.
Sourcepub fn new(ptr: P) -> Self
pub fn new(ptr: P) -> Self
Creates a new fat pointer wrapping the provided pointer. This will immediately get the pointer’s DynDynTable by calling
GetDynDynTable<B>::get_dyn_dyn_table and cache it for future use.
Sourcepub fn get_dyn_dyn_table(ptr: &Self) -> DynDynTable
pub fn get_dyn_dyn_table(ptr: &Self) -> DynDynTable
Gets the DynDynTable of the object referenced by a fat pointer without dereferencing it.
Source§impl<B: ?Sized + DynDynBase, P: DerefMut> DynDynFat<B, P>
impl<B: ?Sized + DynDynBase, P: DerefMut> DynDynFat<B, P>
Sourcepub fn deref_mut_fat(ptr: &mut Self) -> DynDynFat<B, &mut P::Target>
pub fn deref_mut_fat(ptr: &mut Self) -> DynDynFat<B, &mut P::Target>
Dereferences a fat pointer to produce a fat pointer with a mutable reference.
Source§impl<B: ?Sized + DynDynBase, P: Clone> DynDynFat<B, P>
impl<B: ?Sized + DynDynBase, P: Clone> DynDynFat<B, P>
Sourcepub unsafe fn clone_unchecked(ptr: &Self) -> Self
pub unsafe fn clone_unchecked(ptr: &Self) -> Self
Clones a fat pointer without verifying that the DynDynTable held by the new fat pointer is applicable to the cloned pointer.
§Safety
The caller must guarantee that the result of calling ptr.clone() will dereference to an object having the same concrete type as
that pointed to by ptr.
Trait Implementations§
Source§impl<B: ?Sized + DynDynBase, P: Deref + Clone + GetDynDynTable<B>> Clone for DynDynFat<B, P>
impl<B: ?Sized + DynDynBase, P: Deref + Clone + GetDynDynTable<B>> Clone for DynDynFat<B, P>
Source§impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B> + Default> Default for DynDynFat<B, P>
impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B> + Default> Default for DynDynFat<B, P>
Source§impl<'a, B: ?Sized + DynDynBase, P: DowncastUnchecked<'a> + 'a> DowncastUnchecked<'a> for DynDynFat<B, P>
impl<'a, B: ?Sized + DynDynBase, P: DowncastUnchecked<'a> + 'a> DowncastUnchecked<'a> for DynDynFat<B, P>
Source§type DowncastResult<D: ?Sized + 'a> = <P as DowncastUnchecked<'a>>::DowncastResult<D>
type DowncastResult<D: ?Sized + 'a> = <P as DowncastUnchecked<'a>>::DowncastResult<D>
D. Note that this type need not have the same outer wrapper as the
type implementing DowncastUnchecked, since the result of the downcast may involve coercions and dereferences.Source§unsafe fn downcast_unchecked<D: ?Sized + Pointee>(
self,
metadata: <D as Pointee>::Metadata,
) -> Self::DowncastResult<D>
unsafe fn downcast_unchecked<D: ?Sized + Pointee>( self, metadata: <D as Pointee>::Metadata, ) -> Self::DowncastResult<D>
D. Read moreSource§impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B>> From<P> for DynDynFat<B, P>
impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B>> From<P> for DynDynFat<B, P>
Source§impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B>> GetDynDynTable<B> for DynDynFat<B, P>
impl<B: ?Sized + DynDynBase, P: GetDynDynTable<B>> GetDynDynTable<B> for DynDynFat<B, P>
Source§type DynTarget = <P as GetDynDynTable<B>>::DynTarget
type DynTarget = <P as GetDynDynTable<B>>::DynTarget
Send
and Sync in the dyn_dyn_cast! macro.Source§fn get_dyn_dyn_table(&self) -> DynDynTable
fn get_dyn_dyn_table(&self) -> DynDynTable
DynDynTable for the object that this pointer points to.