[][src]Struct dync::VecDrop

pub struct VecDrop<V: ?Sized = (DropFn, ())> where
    V: HasDrop
{ /* fields omitted */ }

Implementations

impl<V: HasDrop> VecDrop<V>[src]

pub fn with_type<T: Elem>() -> Self where
    V: VTable<T>, 
[src]

Construct an empty vector with a specific pointed-to element type.

pub fn with_capacity<T: Elem>(n: usize) -> Self where
    V: VTable<T>, 
[src]

Construct an empty vector with a capacity for a given number of typed pointed-to elements.

pub fn from_vec<T: Elem>(vec: Vec<T>) -> Self where
    V: VTable<T>, 
[src]

Construct a VecDrop from a given Vec reusing the space already allocated by the given vector.

impl<V: ?Sized + HasDrop> VecDrop<V>[src]

pub fn with_type_from(other: impl Into<Meta<Ptr<V>>>) -> Self[src]

Construct a vector with the same type as the given vector without copying its data.

pub unsafe fn from_raw_parts(
    data: Vec<u8>,
    element_size: usize,
    element_type_id: TypeId,
    vtable: Ptr<V>
) -> VecDrop<V>
[src]

Construct a VecDrop from raw bytes and type metadata.

Safety

Almost exclusively the only inputs that are safe here are the ones returned by VecDrop::into_raw_parts.

This function should not be used other than in internal APIs. It exists to enable the into_dyn macro until CoerceUsize is stabilized.

pub fn into_raw_parts(self) -> (Vec<u8>, usize, TypeId, Ptr<V>)[src]

Convert this collection into its raw components.

This function exists mainly to enable the into_dyn macro until CoerceUnsized is stabilized.

pub fn vtable(&self) -> &V[src]

Retrieve the associated virtual function table.

pub fn upcast<U: HasDrop + From<V>>(self) -> VecDrop<U> where
    V: Clone
[src]

Upcast the VecDrop into a more general base VecDrop.

This function converts the underlying virtual function table into a subset of the existing

pub fn clear(&mut self)[src]

Clear the data buffer without destroying its type information.

pub fn push_as<T: Elem>(&mut self, element: T) -> Option<&mut Self>[src]

Add an element to this buffer.

If the type of the given element coincides with the type stored by this buffer, then the modified buffer is returned via a mutable reference. Otherwise, None is returned.

pub fn check<T: Elem>(self) -> Option<Self>[src]

Check if the current buffer contains elements of the specified type. Returns Some(self) if the type matches and None otherwise.

pub fn check_ref<T: Elem>(&self) -> Option<&Self>[src]

Check if the current buffer contains elements of the specified type. Returns None if the check fails, otherwise a reference to self is returned.

pub fn check_mut<T: Elem>(&mut self) -> Option<&mut Self>[src]

Check if the current buffer contains elements of the specified type. Same as check_ref but consumes and produces a mut reference to self.

pub fn element_type_id(&self) -> TypeId[src]

Get the TypeId of data stored within this buffer.

pub fn len(&self) -> usize[src]

Get the number of elements stored in this buffer.

pub fn is_empty(&self) -> bool[src]

Check if there are any elements stored in this buffer.

pub fn byte_capacity(&self) -> usize[src]

Get the byte capacity of this buffer.

pub fn element_size(&self) -> usize[src]

Get the size of the element type in bytes.

pub fn iter_as<T: Elem>(&self) -> Option<Iter<T>>[src]

Return an iterator to a slice representing typed data.

Returns None if the given type T doesn't match the internal.

pub fn iter_mut_as<T: Elem>(&mut self) -> Option<IterMut<T>>[src]

Return an iterator to a mutable slice representing typed data.

Returns None if the given type T doesn't match the internal.

pub fn into_vec<T: Elem>(self) -> Option<Vec<T>>[src]

An alternative to using the Into trait.

This function helps the compiler determine the type T automatically.

pub fn as_slice_as<T: Elem>(&self) -> Option<&[T]>[src]

Convert this buffer into a typed slice. Returs None if the given type T doesn't match the internal.

pub fn as_mut_slice_as<T: Elem>(&mut self) -> Option<&mut [T]>[src]

Convert this buffer into a typed mutable slice. Returs None if the given type T doesn't match the internal.

pub fn get_ref_as<T: Elem>(&self, i: usize) -> Option<&T>[src]

Get a const reference to the i'th element of the buffer.

pub fn get_mut_as<T: Elem>(&mut self, i: usize) -> Option<&mut T>[src]

Get a mutable reference to the i'th element of the buffer.

pub fn append(&mut self, buf: &mut VecDrop<V>) -> Option<&mut Self>[src]

Move bytes to this buffer.

The given buffer must have the same underlying type as self.

pub fn rotate_left(&mut self, mid: usize)[src]

Rotates the slice in-place such that the first mid elements of the slice move to the end while the last self.len() - mid elements move to the front.

After calling rotate_left, the element previously at index mid will become the first element in the slice.

pub fn rotate_right(&mut self, k: usize)[src]

Rotates the slice in-place such that the first self.len() - k elements of the slice move to the end while the last k elements move to the front.

After calling rotate_right, the element previously at index k will become the first element in the slice.

pub fn push<U: ?Sized + HasDrop>(
    &mut self,
    value: BoxValue<U>
) -> Option<&mut Self>
[src]

Push a value onto this buffer.

If the type of the given value coincides with the type stored by this buffer, then the modified buffer is returned via a mutable reference. Otherwise, None is returned.

Note that the vtables need not patch, only the underlying types are required to match.

pub fn push_cloned(&mut self, value: ValueRef<V>) -> Option<&mut Self> where
    V: HasClone
[src]

Push a clone of the referenced value to this buffer.

If the type of the given value coincides with the type stored by this buffer, then the modified buffer is returned via a mutable reference. Otherwise, None is returned.

This is more efficient than push_value since it avoids an extra allocation, however it requires the contained value to be Clone.

pub fn get(&self, i: usize) -> ValueRef<V>[src]

Get a reference to a value stored in this container at index i.

pub fn iter<'a>(&'a self) -> impl Iterator<Item = ValueRef<'a, V>> + 'a[src]

Return an iterator over untyped value references stored in this buffer.

In contrast to iter, this function defers downcasting on a per element basis. As a result, this type of iteration is typically less efficient if a typed value is needed for each element.

pub fn get_mut(&mut self, i: usize) -> ValueMut<V>[src]

Get a mutable reference to a value stored in this container at index i.

pub fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = ValueMut<'a, V>> + 'a where
    V: Clone
[src]

Return an iterator over mutable untyped value references stored in this buffer.

In contrast to iter_mut, this function defers downcasting on a per element basis. As a result, this type of iteration is typically less efficient if a typed value is needed for each element.

pub fn as_slice(&self) -> SliceDrop<V>[src]

pub fn as_mut_slice(&mut self) -> SliceDropMut<V>[src]

pub unsafe fn get_unchecked_ref<T: Any>(&self, i: usize) -> &T[src]

Get a const reference to the i'th element of the vector.

This can be used to reinterpret the internal data as a different type. Note that if the size of the given type T doesn't match the size of the internal type, i will really index the ith T sized chunk in the current vector. See the implementation for details.

Safety

It is assumed that that the vector contains elements of type T and that i is strictly less than the length of this vector, otherwise this function may cause undefined behavior.

This function is a complete opt-out of all safety checks.

pub unsafe fn get_unchecked_mut<T: Any>(&mut self, i: usize) -> &mut T[src]

Get a mutable reference to the i'th element of the vector.

This can be used to reinterpret the internal data as a different type. Note that if the size of the given type T doesn't match the size of the internal type, i will really index the ith T sized chunk in the current vector. See the implementation for details.

Safety

It is assumed that that the vector contains elements of type T and that i is strictly less than the length of this vector, otherwise this function may cause undefined behavior.

This function is opts-out of all safety checks.

impl<V: HasDrop + HasClone> VecDrop<V>[src]

pub fn with_size<T: Elem + Clone>(n: usize, def: T) -> Self where
    V: VTable<T>, 
[src]

Construct a typed DataBuffer with a given size and filled with the specified default value.

pub fn from_slice<T: Elem + Clone>(slice: &[T]) -> Self where
    V: VTable<T>, 
[src]

Construct a buffer from a given slice by cloning the data.

impl<V: ?Sized + HasDrop + HasClone> VecDrop<V>[src]

pub fn resize<T: Elem + Clone>(
    &mut self,
    new_len: usize,
    value: T
) -> Option<&mut Self>
[src]

Resizes the buffer in-place to store new_len elements and returns an optional mutable reference to Self.

If value does not correspond to the underlying element type, then None is returned and the buffer is left unchanged.

This function has the similar properties to Vec::resize.

pub fn fill<T: Elem + Clone>(&mut self, def: T) -> Option<&mut Self>[src]

Fill the current buffer with clones of the given value.

The size of the buffer is left unchanged. If the given type doesn't match the internal type, None is returned, otherwise a mutable reference to the modified buffer is returned.

pub fn append_cloned_to_vec<'a, T: Elem + Clone>(
    &self,
    vec: &'a mut Vec<T>
) -> Option<&'a mut Vec<T>>
[src]

Append cloned items from this buffer to a given Vec.

Return the mutable reference Some(vec) if type matched the internal type and None otherwise.

pub fn clone_into_vec<T: Elem + Clone>(&self) -> Option<Vec<T>>[src]

Clones contents of self into the given Vec.

Trait Implementations

impl<V: ?Sized + Clone + HasDrop + HasClone> Clone for VecDrop<V>[src]

impl<V: ?Sized + HasDrop + HasDebug> Debug for VecDrop<V>[src]

impl<V: ?Sized + HasDrop> Drop for VecDrop<V>[src]

impl<V: ?Sized + HasDrop + HasEq> Eq for VecDrop<V>[src]

impl<'a, T, V> From<&'a [T]> for VecDrop<V> where
    T: Elem + Clone,
    V: HasDrop + VTable<T> + HasClone
[src]

Convert a slice to a VecDrop.

impl<'a, V: Clone + HasDrop> From<&'a VecDrop<V>> for Meta<Ptr<V>>[src]

impl<'a, V: Clone + HasDrop> From<&'a VecDrop<V>> for Meta<VTableRef<'a, V>>[src]

impl<T: Elem, V: HasDrop + VTable<T>> From<Vec<T>> for VecDrop<V>[src]

Convert a Vec to a buffer.

impl<V: ?Sized + HasDrop + HasHash> Hash for VecDrop<V>[src]

impl<T: Elem, V: ?Sized + HasDrop + VTable<T>> Into<Option<Vec<T>>> for VecDrop<V>[src]

Convert a buffer to a Vec with an option to fail.

impl<V: ?Sized + HasDrop + HasPartialEq> PartialEq<VecDrop<V>> for VecDrop<V>[src]

impl<V: ?Sized + HasDrop + HasSend> Send for VecDrop<V>[src]

impl<V: ?Sized + HasDrop + HasSync> Sync for VecDrop<V>[src]

Auto Trait Implementations

impl<V: ?Sized> RefUnwindSafe for VecDrop<V> where
    V: RefUnwindSafe

impl<V: ?Sized> Unpin for VecDrop<V>

impl<V: ?Sized> UnwindSafe for VecDrop<V> where
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneBytes for T where
    T: 'static + Clone
[src]

impl<T> DebugBytes for T where
    T: 'static + Debug
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]

impl<T> DropBytes for T where
    T: 'static, 
[src]

impl<T> From<T> for T[src]

impl<T> HashBytes for T where
    T: 'static + Hash
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> PartialEqBytes for T where
    T: 'static + PartialEq<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.