Skip to main content

ElementPointer

Struct ElementPointer 

Source
pub struct ElementPointer<'a, AnyVecPtr: IAnyVecRawPtr> { /* private fields */ }
Expand description

Owning pointer to type-erased AnyVec element.

Obtained by dereferencing ElementRef, ElementMut or from some destructive AnyVec operations, like drain or splice.

§Consuming

Whenever you have ElementPointer as a value (from destructive AnyVec operations), you can safely take pointed value with AnyValue::downcast, or unsafely take its content with AnyValueSizeless::move_into. Otherwise, it will be destructed with destruction of Element.

§Notes

ElementPointer have it’s own implementation of downcast_ family (which return &'a T, instead of &T). This is done, so you don’t have to keep ElementRef/ElementMut alive, while casting to concrete type.

Implementations§

Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> ElementPointer<'a, AnyVecPtr>

Source

pub fn downcast_ref<T: 'static>(&self) -> Option<&'a T>

Same as AnyValue::downcast_ref, but return &'a T, instead of &T.

Source

pub unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &'a T

Same as AnyValueSizeless::downcast_ref_unchecked, but return &'a T, instead of &T.

Source

pub fn downcast_mut<T: 'static>(&mut self) -> Option<&'a mut T>

Same as AnyValueMut::downcast_mut, but return &'a mut T, instead of &mut T.

Source

pub unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &'a mut T

Same as AnyValueSizelessMut::downcast_mut_unchecked, but return &'a mut T, instead of &mut T.

Trait Implementations§

Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> AnyValue for ElementPointer<'a, AnyVecPtr>

Source§

fn value_typeid(&self) -> TypeId

Source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Source§

fn downcast<T: 'static>(self) -> Option<T>
where Self: Sized,

Source§

impl<'a, Traits: ?Sized + Cloneable + Trait, M: MemBuilder> AnyValueCloneable for ElementPointer<'a, AnyVecPtr<Traits, M>>

Source§

unsafe fn clone_into(&self, out: *mut u8)

Source§

fn lazy_clone(&self) -> LazyClone<'_, Self>
where Self: Sized,

Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> AnyValueMut for ElementPointer<'a, AnyVecPtr>

Source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Source§

fn swap<Other: AnyValueMut>(&mut self, other: &mut Other)

Swaps underlying values. Read more
Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> AnyValueSizeless for ElementPointer<'a, AnyVecPtr>

Source§

type Type = <AnyVecPtr as IAnyVecRawPtr>::Element

Concrete type, or Unknown Read more
Source§

fn as_bytes_ptr(&self) -> *const u8

Aligned address.
Source§

unsafe fn downcast_ref_unchecked<T>(&self) -> &T

Source§

unsafe fn downcast_unchecked<T: 'static>(self) -> T
where Self: Sized,

Source§

unsafe fn move_into<KnownType: 'static>(self, out: *mut u8, bytes_size: usize)
where Self: Sized,

Move self into out. Read more
Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> AnyValueSizelessMut for ElementPointer<'a, AnyVecPtr>

Source§

fn as_bytes_mut_ptr(&mut self) -> *mut u8

Aligned address.
Source§

unsafe fn downcast_mut_unchecked<T>(&mut self) -> &mut T

Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> AnyValueTypeless for ElementPointer<'a, AnyVecPtr>

Source§

fn size(&self) -> usize

Aligned.
Source§

fn as_bytes(&self) -> &[u8]

Aligned.
Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> AnyValueTypelessMut for ElementPointer<'a, AnyVecPtr>

Source§

fn as_bytes_mut(&mut self) -> &mut [u8]

Source§

unsafe fn swap_unchecked<Other: AnyValueMut>(&mut self, other: &mut Other)

Source§

impl<'a, AnyVecPtr: IAnyVecRawPtr> Drop for ElementPointer<'a, AnyVecPtr>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, Traits: ?Sized + Trait, M: MemBuilder> ElementReference<'a, Traits, M> for &'a ElementPointer<'a, AnyVecPtr<Traits, M>>

Source§

impl<'a, Traits: ?Sized + Trait, M: MemBuilder> Send for ElementPointer<'a, AnyVecPtr<Traits, M>>
where AnyVec<Traits, M>: Send,

Source§

impl<'a, Traits: ?Sized + Trait, M: MemBuilder> Sync for ElementPointer<'a, AnyVecPtr<Traits, M>>
where AnyVec<Traits, M>: Sync,

Auto Trait Implementations§

§

impl<'a, AnyVecPtr> Freeze for ElementPointer<'a, AnyVecPtr>
where AnyVecPtr: Freeze,

§

impl<'a, AnyVecPtr> RefUnwindSafe for ElementPointer<'a, AnyVecPtr>
where AnyVecPtr: RefUnwindSafe, <AnyVecPtr as IAnyVecRawPtr>::M: RefUnwindSafe, <<AnyVecPtr as IAnyVecRawPtr>::M as MemBuilder>::Mem: RefUnwindSafe,

§

impl<'a, AnyVecPtr> !Send for ElementPointer<'a, AnyVecPtr>

§

impl<'a, AnyVecPtr> !Sync for ElementPointer<'a, AnyVecPtr>

§

impl<'a, AnyVecPtr> Unpin for ElementPointer<'a, AnyVecPtr>
where AnyVecPtr: Unpin,

§

impl<'a, AnyVecPtr> UnsafeUnpin for ElementPointer<'a, AnyVecPtr>
where AnyVecPtr: UnsafeUnpin,

§

impl<'a, AnyVecPtr> !UnwindSafe for ElementPointer<'a, AnyVecPtr>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> SatisfyTraits<dyn None> for T

Source§

impl<T> SatisfyTraits<dyn Send> for T
where T: Send,

Source§

impl<T> SatisfyTraits<dyn Sync + Send> for T
where T: Send + Sync,

Source§

impl<T> SatisfyTraits<dyn Sync> for T
where T: Sync,