Skip to main content

BoundedMap

Trait BoundedMap 

Source
pub trait BoundedMap<T, N: Get<u32>> {
    // Required methods
    fn map<U>(self, f: impl FnMut(T) -> U) -> BoundedVec<U, N>;
    fn map_ref<U>(&self, f: impl FnMut(&T) -> U) -> BoundedVec<U, N>;
    fn try_map<U, E>(
        self,
        f: impl FnMut(T) -> Result<U, E>,
    ) -> Result<BoundedVec<U, N>, E>;
    fn try_map_ref<U, E>(
        &self,
        f: impl FnMut(&T) -> Result<U, E>,
    ) -> Result<BoundedVec<U, N>, E>;
}
Expand description

Trait for vector types which have a bounded length allowing element-wise transformation.

Required Methods§

Source

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

Element-wise transformation of items using the given function.

  • f: The transformation function.

Returns a new instance with all elements transformed using the function f.

Source

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

Element-wise transformation of item-references using the given function.

  • f: The transformation function.

Returns a new instance with all element-references transformed using the function f.

Source

fn try_map<U, E>( self, f: impl FnMut(T) -> Result<U, E>, ) -> Result<BoundedVec<U, N>, E>

Fallible element-wise transformation of items using the given function.

  • f: The transformation function.

Returns a new instance with all elements transformed using the function f, or Err if any invocation of f resulted in error.

Source

fn try_map_ref<U, E>( &self, f: impl FnMut(&T) -> Result<U, E>, ) -> Result<BoundedVec<U, N>, E>

Fallible element-wise transformation of item-references using the given function.

  • f: The transformation function.

Returns a new instance with all element-references transformed using the function f, or Err if any invocation of f resulted in error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, N: Get<u32>> BoundedMap<T, N> for BoundedVec<T, N>

Source§

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

Source§

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

Source§

fn try_map<U, E>( self, f: impl FnMut(T) -> Result<U, E>, ) -> Result<BoundedVec<U, N>, E>

Source§

fn try_map_ref<U, E>( &self, f: impl FnMut(&T) -> Result<U, E>, ) -> Result<BoundedVec<U, N>, E>

Implementors§