zerovec::maps

Trait MutableZeroVecLike

Source
pub trait MutableZeroVecLike<'a, T: ?Sized>: ZeroVecLike<T> {
    type OwnedType;

    // Required methods
    fn zvl_insert(&mut self, index: usize, value: &T);
    fn zvl_remove(&mut self, index: usize) -> Self::OwnedType;
    fn zvl_replace(&mut self, index: usize, value: &T) -> Self::OwnedType;
    fn zvl_push(&mut self, value: &T);
    fn zvl_with_capacity(cap: usize) -> Self;
    fn zvl_clear(&mut self);
    fn zvl_reserve(&mut self, addl: usize);
    fn zvl_permute(&mut self, permutation: &mut [usize]);
    fn owned_as_t(o: &Self::OwnedType) -> &T;
    fn zvl_from_borrowed(b: &'a Self::SliceVariant) -> Self;
    fn zvl_as_borrowed_inner(&self) -> Option<&'a Self::SliceVariant>;
}
Expand description

Trait abstracting over ZeroVec and VarZeroVec, for use in ZeroMap. You should not be implementing or calling this trait directly.

This trait augments ZeroVecLike with methods allowing for mutation of the underlying vector for owned vector types.

Methods are prefixed with zvl_* to avoid clashes with methods on the types themselves

Required Associated Types§

Source

type OwnedType

The type returned by Self::remove() and Self::replace()

Required Methods§

Source

fn zvl_insert(&mut self, index: usize, value: &T)

Insert an element at index

Source

fn zvl_remove(&mut self, index: usize) -> Self::OwnedType

Remove the element at index (panicking if nonexistant)

Source

fn zvl_replace(&mut self, index: usize, value: &T) -> Self::OwnedType

Replace the element at index with another one, returning the old element

Source

fn zvl_push(&mut self, value: &T)

Push an element to the end of this vector

Source

fn zvl_with_capacity(cap: usize) -> Self

Create a new, empty vector, with given capacity

Source

fn zvl_clear(&mut self)

Remove all elements from the vector

Source

fn zvl_reserve(&mut self, addl: usize)

Reserve space for addl additional elements

Source

fn zvl_permute(&mut self, permutation: &mut [usize])

Applies the permutation such that before.zvl_get(permutation[i]) == after.zvl_get(i).

§Panics

If permutation is not a valid permutation of length zvl_len().

Source

fn owned_as_t(o: &Self::OwnedType) -> &T

Convert an owned value to a borrowed T

Source

fn zvl_from_borrowed(b: &'a Self::SliceVariant) -> Self

Construct from the borrowed version of the type

These are useful to ensure serialization parity between borrowed and owned versions

Source

fn zvl_as_borrowed_inner(&self) -> Option<&'a Self::SliceVariant>

Extract the inner borrowed variant if possible. Returns None if the data is owned.

This function behaves like &'_ self -> Self::SliceVariant<'a>, where 'a is the lifetime of this object’s borrowed data.

This function is similar to matching the Borrowed variant of ZeroVec or VarZeroVec, returning the inner borrowed type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> MutableZeroVecLike<'a, usize> for FlexZeroVec<'a>

Source§

impl<'a, T> MutableZeroVecLike<'a, T> for ZeroVec<'a, T>
where T: AsULE + Copy + 'static,

Source§

impl<'a, T, F> MutableZeroVecLike<'a, T> for VarZeroVec<'a, T, F>
where T: VarULE + ?Sized, F: VarZeroVecFormat,