[−][src]Struct dync::VecDyn
This container is a WIP, not to be used in production.
Methods
impl<V> VecDyn<V>
[src]
pub fn vtable(&self) -> &V
[src]
Retrieve the associated virtual function table.
pub fn with_type<T: Elem>() -> Self where
V: VTable<T>,
[src]
V: VTable<T>,
Construct an empty vector with a specific pointed-to element type.
pub fn with_type_from(other: &VecDyn<V>) -> Self
[src]
Construct a vector with the same type as the given vector without copying its data.
pub fn with_capacity<T: Elem>(n: usize) -> Self where
V: VTable<T>,
[src]
V: VTable<T>,
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]
V: VTable<T>,
Construct a VecDyn
from a given Vec
reusing the space already allocated by the given
vector.
pub fn clear(&mut self)
[src]
Clear the data buffer without destroying its type information.
pub fn push<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<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<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 VecDyn<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_value(&mut self, value: BoxValue<V>) -> 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.
pub fn push_cloned(&mut self, value: ValueRef<V>) -> Option<&mut Self> where
V: HasClone,
[src]
V: HasClone,
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
[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.
impl<V: HasClone> VecDyn<V>
[src]
pub fn with_size<T: Elem + Clone>(n: usize, def: T) -> Self where
V: VTable<T>,
[src]
V: VTable<T>,
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]
V: VTable<T>,
Construct a buffer from a given slice by cloning the data.
pub fn resize<T: Elem + Clone>(
&mut self,
new_len: usize,
value: T
) -> Option<&mut Self>
[src]
&mut self,
new_len: usize,
value: T
) -> Option<&mut Self>
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]
&self,
vec: &'a mut Vec<T>
) -> Option<&'a mut Vec<T>>
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: HasClone> Clone for VecDyn<V>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<V: HasDebug> Debug for VecDyn<V>
[src]
impl<V> Drop for VecDyn<V>
[src]
impl<V: HasEq> Eq for VecDyn<V>
[src]
impl<'a, T, V> From<&'a [T]> for VecDyn<V> where
T: Elem + Clone,
V: VTable<T> + HasClone,
[src]
T: Elem + Clone,
V: VTable<T> + HasClone,
Convert a slice to a VecDyn
.
impl<T: Elem, V: VTable<T>> From<Vec<T>> for VecDyn<V>
[src]
Convert a Vec
to a buffer.
impl<V: HasHash> Hash for VecDyn<V>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Elem, V: VTable<T>> Into<Option<Vec<T>>> for VecDyn<V>
[src]
Convert a buffer to a Vec
with an option to fail.
impl<V: HasPartialEq> PartialEq<VecDyn<V>> for VecDyn<V>
[src]
Auto Trait Implementations
impl<V> RefUnwindSafe for VecDyn<V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
impl<V> Send for VecDyn<V> where
V: Send + Sync,
V: Send + Sync,
impl<V> Sync for VecDyn<V> where
V: Send + Sync,
V: Send + Sync,
impl<V> Unpin for VecDyn<V>
impl<V> UnwindSafe for VecDyn<V> where
V: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,