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>
impl<'a, AnyVecPtr: IAnyVecRawPtr> ElementPointer<'a, AnyVecPtr>
Sourcepub fn downcast_ref<T: 'static>(&self) -> Option<&'a T>
pub fn downcast_ref<T: 'static>(&self) -> Option<&'a T>
Same as AnyValue::downcast_ref, but return &'a T, instead of &T.
Sourcepub unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &'a T
pub unsafe fn downcast_ref_unchecked<T: 'static>(&self) -> &'a T
Same as AnyValueSizeless::downcast_ref_unchecked, but return &'a T, instead of &T.
Sourcepub fn downcast_mut<T: 'static>(&mut self) -> Option<&'a mut T>
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.
Sourcepub unsafe fn downcast_mut_unchecked<T: 'static>(&mut self) -> &'a mut T
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.