Expand description
Implementations
sourceimpl 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);
sourceimpl<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
method name was misspelled, use the correct spelling instead
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.
Trait Implementations
impl<B: ?Sized + Send> Send for VecAny<B>
impl<B: ?Sized + Sync> Sync for VecAny<B>
Auto Trait Implementations
impl<B: ?Sized> RefUnwindSafe for VecAny<B> where
B: RefUnwindSafe,
impl<B: ?Sized> Unpin for VecAny<B> where
B: Unpin,
impl<B: ?Sized> UnwindSafe for VecAny<B> where
B: UnwindSafe,
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