pub struct FixedVec<T, N: Get<u32>>(/* private fields */);Expand description
Vector type with a fixed length.
Can be used similarly to an array but which stores its elements on the heap.
Implementations§
Source§impl<T, N: Get<u32>> FixedVec<T, N>
impl<T, N: Get<u32>> FixedVec<T, N>
pub fn new(t: T) -> Selfwhere
T: Clone,
pub fn from_fn(f: impl FnMut(usize) -> T) -> Self
pub fn get(&self, i: usize) -> Option<&T>
pub fn get_mut(&mut self, i: usize) -> Option<&mut T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Iter<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn map<U>(self, f: impl FnMut(T) -> U) -> FixedVec<U, N>
pub fn map_ref<U>(&self, f: impl FnMut(&T) -> U) -> FixedVec<U, N>
pub fn to_bounded(self) -> BoundedVec<T, N>
pub fn to_vec(self) -> Vec<T>
pub fn into_vec(self) -> Vec<T>
pub fn truncate_into_vec(self, len: usize) -> Vec<T>
pub fn slide(&mut self, index: usize, insert_at: usize)
pub fn force_insert_keep_left( &mut self, index: usize, element: T, ) -> Result<Option<T>, T>
pub fn force_insert_keep_right( &mut self, index: usize, element: T, ) -> Result<Option<T>, T>
pub fn force_push(&mut self, element: T)
pub fn swap(&mut self, a: usize, b: usize)
pub fn as_ptr(&self) -> *const T
pub fn as_mut_ptr(&mut self) -> *mut T
Trait Implementations§
Source§impl<T: Decode, N: Get<u32>> Decode for FixedVec<T, N>
impl<T: Decode, N: Get<u32>> Decode for FixedVec<T, N>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, DecodeError>
fn decode<I: Input>(input: &mut I) -> Result<Self, DecodeError>
Attempt to deserialise the value from input.
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl<T: Encode, N: Get<u32>> Encode for FixedVec<T, N>
impl<T: Encode, N: Get<u32>> Encode for FixedVec<T, N>
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
Source§fn encode_to<D: Output + ?Sized>(&self, dest: &mut D)
fn encode_to<D: Output + ?Sized>(&self, dest: &mut D)
Convert self to a slice and append it to the destination.
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl<T, N: Get<u32>> From<FixedVec<T, N>> for BoundedVec<T, N>
impl<T, N: Get<u32>> From<FixedVec<T, N>> for BoundedVec<T, N>
Source§fn from(s: FixedVec<T, N>) -> BoundedVec<T, N>
fn from(s: FixedVec<T, N>) -> BoundedVec<T, N>
Converts to this type from the input type.
Source§impl<T: MaxEncodedLen, N: Get<u32>> MaxEncodedLen for FixedVec<T, N>
impl<T: MaxEncodedLen, N: Get<u32>> MaxEncodedLen for FixedVec<T, N>
Source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
impl<T: ConstEncodedLen, N: Get<u32>> ConstEncodedLen for FixedVec<T, N>
impl<T, N: Get<u32>> Eq for FixedVec<T, N>where
T: Eq,
Auto Trait Implementations§
impl<T, N> Freeze for FixedVec<T, N>
impl<T, N> RefUnwindSafe for FixedVec<T, N>where
N: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, N> Send for FixedVec<T, N>
impl<T, N> Sync for FixedVec<T, N>
impl<T, N> Unpin for FixedVec<T, N>
impl<T, N> UnwindSafe for FixedVec<T, N>where
N: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T, U> AsByteSlice<T> for U
impl<T, U> AsByteSlice<T> for U
fn as_byte_slice(&self) -> &[u8] ⓘ
Source§impl<T, U> AsMutByteSlice<T> for U
impl<T, U> AsMutByteSlice<T> for U
fn as_mut_byte_slice(&mut self) -> &mut [u8] ⓘ
Source§impl<U> AsMutSliceOf for U
impl<U> AsMutSliceOf for U
fn as_mut_slice_of<T>(&mut self) -> Result<&mut [T], Error>where
T: FromByteSlice,
Source§impl<U> AsSliceOf for U
impl<U> AsSliceOf for U
fn as_slice_of<T>(&self) -> Result<&[T], Error>where
T: FromByteSlice,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more