liblisa::utils

Trait MapRotated

pub trait MapRotated {
    type Item;
    type Output<I>;

    // Required method
    fn map_rotated<I>(
        self,
        start: usize,
        f: impl FnMut(Self::Item) -> I,
    ) -> Self::Output<I>;
}
Expand description

Convenience trait that rotates elements in a slice, and maps them to a new value.

Required Associated Types§

type Item

The items in the slice.

type Output<I>

The output type of MapRotated::Output.

Required Methods§

fn map_rotated<I>( self, start: usize, f: impl FnMut(Self::Item) -> I, ) -> Self::Output<I>

Returns an iterator that maps every value to another value using f, but rotates the results by start positions. This means that the iterator returns f(self[start]), f(self[start + 1]), .., f(self[0]), f(self[1]), .., f(self[start - 1]).

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.

Implementations on Foreign Types§

§

impl<const N: usize, T> MapRotated for [T; N]
where T: Copy,

§

type Item = T

§

type Output<I> = [I; N]

§

fn map_rotated<I>( self, start: usize, f: impl FnMut(Self::Item) -> I, ) -> Self::Output<I>

Implementors§