Type Alias frame_support::traits::BoundedInline
source · pub type BoundedInline = BoundedVec<u8, ConstU32<128>>;
Aliased Type§
struct BoundedInline(/* private fields */);
Implementations
source§impl<T, S> BoundedVec<T, S>
impl<T, S> BoundedVec<T, S>
sourcepub fn new() -> BoundedVec<T, S>
pub fn new() -> BoundedVec<T, S>
Create Self
with no items.
sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Consume self, and return the inner Vec
. Henceforth, the Vec<_>
can be altered in an
arbitrary way. At some point, if the reverse conversion is required, TryFrom<Vec<_>>
can
be used.
This is useful for cases if you need access to an internal API of the inner Vec<_>
which
is not provided by the wrapper BoundedVec
.
sourcepub fn sort_by<F>(&mut self, compare: F)
pub fn sort_by<F>(&mut self, compare: F)
Exactly the same semantics as slice::sort_by
.
This is safe since sorting cannot change the number of elements in the vector.
sourcepub fn sort_by_key<K, F>(&mut self, f: F)
pub fn sort_by_key<K, F>(&mut self, f: F)
Exactly the same semantics as slice::sort_by_key
.
This is safe since sorting cannot change the number of elements in the vector.
sourcepub fn sort(&mut self)where
T: Ord,
pub fn sort(&mut self)where
T: Ord,
Exactly the same semantics as slice::sort
.
This is safe since sorting cannot change the number of elements in the vector.
sourcepub fn swap_remove(&mut self, index: usize) -> T
pub fn swap_remove(&mut self, index: usize) -> T
sourcepub fn get_mut<I>(
&mut self,
index: I,
) -> Option<&mut <I as SliceIndex<[T]>>::Output>where
I: SliceIndex<[T]>,
pub fn get_mut<I>(
&mut self,
index: I,
) -> Option<&mut <I as SliceIndex<[T]>>::Output>where
I: SliceIndex<[T]>,
Exactly the same semantics as slice::get_mut
.
sourcepub fn truncate(&mut self, s: usize)
pub fn truncate(&mut self, s: usize)
Exactly the same semantics as Vec::truncate
.
This is safe because truncate
can never increase the length of the internal vector.
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Exactly the same semantics as Vec::pop
.
This is safe since popping can only shrink the inner vector.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, T> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T> ⓘ
Exactly the same semantics as slice::iter_mut
.
sourcepub fn last_mut(&mut self) -> Option<&mut T>
pub fn last_mut(&mut self) -> Option<&mut T>
Exactly the same semantics as slice::last_mut
.
sourcepub fn drain<R>(&mut self, range: R) -> Drain<'_, T> ⓘwhere
R: RangeBounds<usize>,
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T> ⓘwhere
R: RangeBounds<usize>,
Exact same semantics as Vec::drain
.
source§impl<T, S> BoundedVec<T, S>
impl<T, S> BoundedVec<T, S>
sourcepub fn with_bounded_capacity(capacity: usize) -> BoundedVec<T, S>
pub fn with_bounded_capacity(capacity: usize) -> BoundedVec<T, S>
Pre-allocate capacity
items in self.
If capacity
is greater than Self::bound
, then the minimum of the two is used.
sourcepub fn with_max_capacity() -> BoundedVec<T, S>
pub fn with_max_capacity() -> BoundedVec<T, S>
Allocate self with the maximum possible capacity.
sourcepub fn truncate_from(v: Vec<T>) -> BoundedVec<T, S>
pub fn truncate_from(v: Vec<T>) -> BoundedVec<T, S>
Consume and truncate the vector v
in order to create a new instance of Self
from it.
sourcepub fn force_insert_keep_right(
&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>
Forces the insertion of element
into self
retaining all items with index at least
index
.
If index == 0
and self.len() == Self::bound()
, then this is a no-op.
If Self::bound() < index
or self.len() < index
, then this is also a no-op.
Returns Ok(maybe_removed)
if the item was inserted, where maybe_removed
is
Some(removed)
if an item was removed to make room for the new one. Returns Err(element)
if element
cannot be inserted.
sourcepub fn force_insert_keep_left(
&mut self,
index: usize,
element: T,
) -> Result<Option<T>, T>
pub fn force_insert_keep_left( &mut self, index: usize, element: T, ) -> Result<Option<T>, T>
Forces the insertion of element
into self
retaining all items with index at most
index
.
If index == Self::bound()
and self.len() == Self::bound()
, then this is a no-op.
If Self::bound() < index
or self.len() < index
, then this is also a no-op.
Returns Ok(maybe_removed)
if the item was inserted, where maybe_removed
is
Some(removed)
if an item was removed to make room for the new one. Returns Err(element)
if element
cannot be inserted.
sourcepub fn slide(&mut self, index: usize, insert_position: usize) -> bool
pub fn slide(&mut self, index: usize, insert_position: usize) -> bool
Move the position of an item from one location to another in the slice.
Except for the item being moved, the order of the slice remains the same.
index
is the location of the item to be moved.insert_position
is the index of the item in the slice which should immediately follow the item which is being moved.
Returns true
of the operation was successful, otherwise false
if a noop.
sourcepub fn force_push(&mut self, element: T)
pub fn force_push(&mut self, element: T)
Forces the insertion of s
into self
truncating first if necessary.
Infallible, but if the bound is zero, then it’s a no-op.
sourcepub fn bounded_resize(&mut self, size: usize, value: T)where
T: Clone,
pub fn bounded_resize(&mut self, size: usize, value: T)where
T: Clone,
Same as Vec::resize
, but if size
is more than Self::bound
, then Self::bound
is
used.
sourcepub fn try_extend(
&mut self,
with: impl IntoIterator<Item = T> + ExactSizeIterator,
) -> Result<(), ()>
pub fn try_extend( &mut self, with: impl IntoIterator<Item = T> + ExactSizeIterator, ) -> Result<(), ()>
Exactly the same semantics as Vec::extend
, but returns an error and does nothing if the
length of the outcome is larger than the bound.
sourcepub fn try_append(&mut self, other: &mut Vec<T>) -> Result<(), ()>
pub fn try_append(&mut self, other: &mut Vec<T>) -> Result<(), ()>
Exactly the same semantics as Vec::append
, but returns an error and does nothing if the
length of the outcome is larger than the bound.
sourcepub fn try_mutate(
self,
mutate: impl FnMut(&mut Vec<T>),
) -> Option<BoundedVec<T, S>>
pub fn try_mutate( self, mutate: impl FnMut(&mut Vec<T>), ) -> Option<BoundedVec<T, S>>
Consumes self and mutates self via the given mutate
function.
If the outcome of mutation is within bounds, Some(Self)
is returned. Else, None
is
returned.
This is essentially a consuming shorthand Self::into_inner
-> ...
->
Self::try_from
.
sourcepub fn try_insert(&mut self, index: usize, element: T) -> Result<(), T>
pub fn try_insert(&mut self, index: usize, element: T) -> Result<(), T>
Exactly the same semantics as Vec::insert
, but returns an Err
(and is a noop) if the
new length of the vector exceeds S
.
§Panics
Panics if index > len
.
source§impl<T, S> BoundedVec<T, S>
impl<T, S> BoundedVec<T, S>
sourcepub fn as_bounded_slice(&self) -> BoundedSlice<'_, T, S>
pub fn as_bounded_slice(&self) -> BoundedSlice<'_, T, S>
Return a BoundedSlice
with the content and bound of Self
.
Trait Implementations
source§impl<T, S> AsMut<[T]> for BoundedVec<T, S>
impl<T, S> AsMut<[T]> for BoundedVec<T, S>
source§impl<T, S> AsRef<[T]> for BoundedVec<T, S>
impl<T, S> AsRef<[T]> for BoundedVec<T, S>
source§impl<T, S> AsRef<Vec<T>> for BoundedVec<T, S>
impl<T, S> AsRef<Vec<T>> for BoundedVec<T, S>
source§impl<T, S> Clone for BoundedVec<T, S>where
T: Clone,
impl<T, S> Clone for BoundedVec<T, S>where
T: Clone,
source§fn clone(&self) -> BoundedVec<T, S>
fn clone(&self) -> BoundedVec<T, S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T, S> Debug for BoundedVec<T, S>
impl<T, S> Debug for BoundedVec<T, S>
source§impl<T, S> Decode for BoundedVec<T, S>
impl<T, S> Decode for BoundedVec<T, S>
source§fn decode<I>(input: &mut I) -> Result<BoundedVec<T, S>, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<BoundedVec<T, S>, Error>where
I: Input,
source§fn skip<I>(input: &mut I) -> Result<(), Error>where
I: Input,
fn skip<I>(input: &mut I) -> Result<(), Error>where
I: 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,
source§impl<T, S> DecodeLength for BoundedVec<T, S>
impl<T, S> DecodeLength for BoundedVec<T, S>
source§impl<T, S> Default for BoundedVec<T, S>
impl<T, S> Default for BoundedVec<T, S>
source§fn default() -> BoundedVec<T, S>
fn default() -> BoundedVec<T, S>
source§impl<T, S> Deref for BoundedVec<T, S>
impl<T, S> Deref for BoundedVec<T, S>
source§impl<'de, T, S> Deserialize<'de> for BoundedVec<T, S>
impl<'de, T, S> Deserialize<'de> for BoundedVec<T, S>
source§fn deserialize<D>(
deserializer: D,
) -> Result<BoundedVec<T, S>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<BoundedVec<T, S>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<T, S> Encode for BoundedVec<T, S>
impl<T, S> Encode for BoundedVec<T, S>
source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
source§fn encode_to<__CodecOutputEdqy>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
source§impl<T, S> Hash for BoundedVec<T, S>where
T: Hash,
impl<T, S> Hash for BoundedVec<T, S>where
T: Hash,
source§impl<T, S, I> Index<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
impl<T, S, I> Index<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
source§impl<T, S, I> IndexMut<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
impl<T, S, I> IndexMut<I> for BoundedVec<T, S>where
I: SliceIndex<[T]>,
source§impl<T, S> IntoIterator for BoundedVec<T, S>
impl<T, S> IntoIterator for BoundedVec<T, S>
source§impl<T, S> MaxEncodedLen for BoundedVec<T, S>
impl<T, S> MaxEncodedLen for BoundedVec<T, S>
source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
source§impl<T, Bound> Ord for BoundedVec<T, Bound>
impl<T, Bound> Ord for BoundedVec<T, Bound>
source§fn cmp(&self, other: &BoundedVec<T, Bound>) -> Ordering
fn cmp(&self, other: &BoundedVec<T, Bound>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<'a, T, BoundSelf, BoundRhs> PartialEq<BoundedSlice<'a, T, BoundRhs>> for BoundedVec<T, BoundSelf>
impl<'a, T, BoundSelf, BoundRhs> PartialEq<BoundedSlice<'a, T, BoundRhs>> for BoundedVec<T, BoundSelf>
source§fn eq(&self, rhs: &BoundedSlice<'a, T, BoundRhs>) -> bool
fn eq(&self, rhs: &BoundedSlice<'a, T, BoundRhs>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T, BoundSelf, BoundRhs> PartialEq<BoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
impl<T, BoundSelf, BoundRhs> PartialEq<BoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
source§fn eq(&self, rhs: &BoundedVec<T, BoundRhs>) -> bool
fn eq(&self, rhs: &BoundedVec<T, BoundRhs>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T, S> PartialEq<Vec<T>> for BoundedVec<T, S>
impl<T, S> PartialEq<Vec<T>> for BoundedVec<T, S>
source§impl<T, BoundSelf, BoundRhs> PartialEq<WeakBoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
impl<T, BoundSelf, BoundRhs> PartialEq<WeakBoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
source§fn eq(&self, rhs: &WeakBoundedVec<T, BoundRhs>) -> bool
fn eq(&self, rhs: &WeakBoundedVec<T, BoundRhs>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, T, BoundSelf, BoundRhs> PartialOrd<BoundedSlice<'a, T, BoundRhs>> for BoundedVec<T, BoundSelf>
impl<'a, T, BoundSelf, BoundRhs> PartialOrd<BoundedSlice<'a, T, BoundRhs>> for BoundedVec<T, BoundSelf>
source§fn partial_cmp(&self, other: &BoundedSlice<'a, T, BoundRhs>) -> Option<Ordering>
fn partial_cmp(&self, other: &BoundedSlice<'a, T, BoundRhs>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T, BoundSelf, BoundRhs> PartialOrd<BoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
impl<T, BoundSelf, BoundRhs> PartialOrd<BoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
source§fn partial_cmp(&self, other: &BoundedVec<T, BoundRhs>) -> Option<Ordering>
fn partial_cmp(&self, other: &BoundedVec<T, BoundRhs>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T, BoundSelf, BoundRhs> PartialOrd<WeakBoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
impl<T, BoundSelf, BoundRhs> PartialOrd<WeakBoundedVec<T, BoundRhs>> for BoundedVec<T, BoundSelf>
source§fn partial_cmp(&self, other: &WeakBoundedVec<T, BoundRhs>) -> Option<Ordering>
fn partial_cmp(&self, other: &WeakBoundedVec<T, BoundRhs>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more