pub struct VecAny<B: ?Sized = dyn Any + Send + Sync> { /* private fields */ }Expand description
Implementations§
Source§impl VecAny
impl VecAny
Sourcepub fn opaque() -> Self
pub fn opaque() -> Self
Create a new, empty, VecAny for which downcasting will always
return None.
Sourcepub fn deferred() -> Self
pub fn deferred() -> Self
Create a new, empty, VecAny with a internal type deferred until
the first mutable downcast. Note that, until this type is otherwise
downcast, downcast_slice will always succeed.
use list_any::VecAny;
let mut v = VecAny::deferred();
assert_eq!(v.downcast_slice::<f64>(), Some(&[][..]));
assert_eq!(v.downcast_slice_mut::<u32>(), Some(&mut [][..]));
assert_eq!(v.downcast_slice::<f64>(), None);Source§impl<B: ?Sized> VecAny<B>
impl<B: ?Sized> VecAny<B>
Sourcepub fn capcaity(&self) -> usize
👎Deprecated since 0.2.1: method name was misspelled, use the correct spelling instead
pub fn capcaity(&self) -> usize
Returns the number of elements the vector can hold without reallocating.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the vector can hold without reallocating.
Sourcepub fn type_id_of_element(&self) -> TypeId
pub fn type_id_of_element(&self) -> TypeId
Returns the TypeId of the elements contained within the vector.
use core::any::TypeId;
use list_any::VecAny;
let data: Vec<u8> = b"hello".to_vec();
let vec_any: VecAny = VecAny::from(data);
assert_eq!(vec_any.type_id_of_element(), TypeId::of::<u8>());Sourcepub fn as_slice_any(&self) -> SliceAny<'_>
pub fn as_slice_any(&self) -> SliceAny<'_>
Sourcepub fn as_slice_any_mut(&mut self) -> SliceAnyMut<'_>
pub fn as_slice_any_mut(&mut self) -> SliceAnyMut<'_>
Returns a mutable borrow of this VecAny as a SliceAnyMut.
Sourcepub fn downcast_mut<T: AnyBound<B>>(&mut self) -> Option<VecAnyGuard<'_, T, B>>
pub fn downcast_mut<T: AnyBound<B>>(&mut self) -> Option<VecAnyGuard<'_, T, B>>
Sourcepub fn downcast_slice<T: AnyBound<B>>(&self) -> Option<&[T]>
pub fn downcast_slice<T: AnyBound<B>>(&self) -> Option<&[T]>
Returns some reference to the contained vector as a slice if the
contained elements are of type T, or None if they are not.
Sourcepub fn downcast_slice_mut<T: AnyBound<B>>(&mut self) -> Option<&mut [T]>
pub fn downcast_slice_mut<T: AnyBound<B>>(&mut self) -> Option<&mut [T]>
Returns some mutable reference to the contained vector as a slice if
the contained elements are of type T, or None if they are not.