Struct FixedVec

Source
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>

Source

pub fn new(t: T) -> Self
where T: Clone,

Source

pub fn padded(t: &[T]) -> Self
where T: Default + Clone,

Source

pub fn from_fn(f: impl FnMut(usize) -> T) -> Self

Source

pub fn get(&self, i: usize) -> Option<&T>

Source

pub fn get_mut(&mut self, i: usize) -> Option<&mut T>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter(&self) -> Iter<'_, T>

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Source

pub fn map<U>(self, f: impl FnMut(T) -> U) -> FixedVec<U, N>

Source

pub fn map_ref<U>(&self, f: impl FnMut(&T) -> U) -> FixedVec<U, N>

Source

pub fn to_bounded(self) -> BoundedVec<T, N>

Source

pub fn to_vec(self) -> Vec<T>

Source

pub fn into_vec(self) -> Vec<T>

Source

pub fn truncate_into_vec(self, len: usize) -> Vec<T>

Source

pub fn slide(&mut self, index: usize, insert_at: usize)

Source

pub fn force_insert_keep_left( &mut self, index: usize, element: T, ) -> Result<Option<T>, T>

Source

pub fn force_insert_keep_right( &mut self, index: usize, element: T, ) -> Result<Option<T>, T>

Source

pub fn force_push(&mut self, element: T)

Source

pub fn swap(&mut self, a: usize, b: usize)

Source

pub fn as_slice(&self) -> &[T]

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Source

pub fn as_ptr(&self) -> *const T

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Trait Implementations§

Source§

impl<T, N: Get<u32>> AsMut<[T]> for FixedVec<T, N>

Source§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, N: Get<u32>> AsRef<[T]> for FixedVec<T, N>

Source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone, N: Get<u32>> Clone for FixedVec<T, N>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, N: Get<u32>> Debug for FixedVec<T, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Decode, N: Get<u32>> Decode for FixedVec<T, N>

Source§

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,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
Source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
Source§

impl<T: Default, N: Get<u32>> Default for FixedVec<T, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<N: Get<u32>> Display for FixedVec<u8, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Encode, N: Get<u32>> Encode for FixedVec<T, N>

Source§

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)

Convert self to a slice and append it to the destination.
Source§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
Source§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
Source§

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>

Source§

fn from(s: FixedVec<T, N>) -> BoundedVec<T, N>

Converts to this type from the input type.
Source§

impl<T, N: Get<u32>> From<FixedVec<T, N>> for Vec<T>

Source§

fn from(s: FixedVec<T, N>) -> Vec<T>

Converts to this type from the input type.
Source§

impl<T, N: Get<u32>> Index<Range<usize>> for FixedVec<T, N>

Source§

type Output = [T]

The returned type after indexing.
Source§

fn index(&self, index: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, N: Get<u32>> Index<RangeFull> for FixedVec<T, N>

Source§

type Output = [T]

The returned type after indexing.
Source§

fn index(&self, index: RangeFull) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, N: Get<u32>> Index<usize> for FixedVec<T, N>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, N: Get<u32>> IndexMut<Range<usize>> for FixedVec<T, N>

Source§

fn index_mut(&mut self, index: Range<usize>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T, N: Get<u32>> IndexMut<RangeFull> for FixedVec<T, N>

Source§

fn index_mut(&mut self, index: RangeFull) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T, N: Get<u32>> IndexMut<usize> for FixedVec<T, N>

Source§

fn index_mut(&mut self, i: usize) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: MaxEncodedLen, N: Get<u32>> MaxEncodedLen for FixedVec<T, N>

Source§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
Source§

impl<T: PartialEq, N: Get<u32>> PartialEq for FixedVec<T, N>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T: Clone, N: Get<u32>> TryFrom<&'a [T]> for FixedVec<T, N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(v: &'a [T]) -> Result<Self, ()>

Performs the conversion.
Source§

impl<T, N: Get<u32>> TryFrom<BoundedVec<T, N>> for FixedVec<T, N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(v: BoundedVec<T, N>) -> Result<Self, ()>

Performs the conversion.
Source§

impl<T, N: Get<u32>> TryFrom<Vec<T>> for FixedVec<T, N>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(v: Vec<T>) -> Result<Self, ()>

Performs the conversion.
Source§

impl<T: ConstEncodedLen, N: Get<u32>> ConstEncodedLen for FixedVec<T, N>

Source§

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>

§

impl<T, N> Send for FixedVec<T, N>
where N: Send, T: Send,

§

impl<T, N> Sync for FixedVec<T, N>
where N: Sync, T: Sync,

§

impl<T, N> Unpin for FixedVec<T, N>
where N: Unpin, T: Unpin,

§

impl<T, N> UnwindSafe for FixedVec<T, N>
where N: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsByteSlice<T> for U
where T: ToByteSlice, U: AsRef<[T]> + ?Sized,

Source§

fn as_byte_slice(&self) -> &[u8]

Source§

impl<T, U> AsMutByteSlice<T> for U
where T: ToMutByteSlice, U: AsMut<[T]> + ?Sized,

Source§

fn as_mut_byte_slice(&mut self) -> &mut [u8]

Source§

impl<U> AsMutSliceOf for U
where U: AsMut<[u8]> + ?Sized,

Source§

fn as_mut_slice_of<T>(&mut self) -> Result<&mut [T], Error>
where T: FromByteSlice,

Source§

impl<U> AsSliceOf for U
where U: AsRef<[u8]> + ?Sized,

Source§

fn as_slice_of<T>(&self) -> Result<&[T], Error>
where T: FromByteSlice,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DecodeAll for T
where T: Decode,

Source§

fn decode_all(input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

impl<T> DecodeLimit for T
where T: Decode,

Source§

fn decode_all_with_depth_limit( limit: u32, input: &mut &[u8], ) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>
where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> KeyedVec for T
where T: Codec,

Source§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S> Codec for S
where S: Decode + Encode,

Source§

impl<T> EncodeLike<&&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

Source§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

Source§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

Source§

impl<'a, T> EncodeLike<Cow<'a, T>> for T
where T: ToOwned + Encode,

Source§

impl<T> EncodeLike<Rc<T>> for T
where T: Encode,

Source§

impl<T> JsonSchemaMaybe for T