Trait ArrayAdjacentPairs

Source
pub trait ArrayAdjacentPairs {
    type T;
    type AdjacentPairs;

    // Required method
    fn pair_adjacent_maybe_odd(self, fallback: Self::T) -> Self::AdjacentPairs;
}
Expand description

An array for which vectoreyes has implemented adjacent pairing operations

This is implemented for all arrays of size 0..=32

Required Associated Types§

Source

type T

The type contained in this array

Source

type AdjacentPairs

An array which is [Self::T; ceil(Self::LEN / 2)]

Required Methods§

Source

fn pair_adjacent_maybe_odd(self, fallback: Self::T) -> Self::AdjacentPairs

Turn an array into an array of pairs where each element is paired with an adjacent element. If the array has odd length, use the fallback.

§Example
use vectoreyes::array_utils::*;
assert_eq!(
    [0, 1, 2, 3].pair_adjacent_maybe_odd(42),
    [(0, 1), (2, 3)]
);
assert_eq!(
    [0, 1, 2, 3, 4].pair_adjacent_maybe_odd(42),
    [(0, 1), (2, 3), (4, 42)]
);

Implementations on Foreign Types§

Source§

impl<T> ArrayAdjacentPairs for [T; 0]

Source§

impl<T> ArrayAdjacentPairs for [T; 1]

Source§

impl<T> ArrayAdjacentPairs for [T; 2]

Source§

impl<T> ArrayAdjacentPairs for [T; 3]

Source§

impl<T> ArrayAdjacentPairs for [T; 4]

Source§

impl<T> ArrayAdjacentPairs for [T; 5]

Source§

impl<T> ArrayAdjacentPairs for [T; 6]

Source§

impl<T> ArrayAdjacentPairs for [T; 7]

Source§

impl<T> ArrayAdjacentPairs for [T; 8]

Source§

impl<T> ArrayAdjacentPairs for [T; 9]

Source§

impl<T> ArrayAdjacentPairs for [T; 10]

Source§

impl<T> ArrayAdjacentPairs for [T; 11]

Source§

impl<T> ArrayAdjacentPairs for [T; 12]

Source§

impl<T> ArrayAdjacentPairs for [T; 13]

Source§

impl<T> ArrayAdjacentPairs for [T; 14]

Source§

impl<T> ArrayAdjacentPairs for [T; 15]

Source§

impl<T> ArrayAdjacentPairs for [T; 16]

Source§

impl<T> ArrayAdjacentPairs for [T; 17]

Source§

impl<T> ArrayAdjacentPairs for [T; 18]

Source§

impl<T> ArrayAdjacentPairs for [T; 19]

Source§

impl<T> ArrayAdjacentPairs for [T; 20]

Source§

impl<T> ArrayAdjacentPairs for [T; 21]

Source§

impl<T> ArrayAdjacentPairs for [T; 22]

Source§

impl<T> ArrayAdjacentPairs for [T; 23]

Source§

impl<T> ArrayAdjacentPairs for [T; 24]

Source§

impl<T> ArrayAdjacentPairs for [T; 25]

Source§

impl<T> ArrayAdjacentPairs for [T; 26]

Source§

impl<T> ArrayAdjacentPairs for [T; 27]

Source§

impl<T> ArrayAdjacentPairs for [T; 28]

Source§

impl<T> ArrayAdjacentPairs for [T; 29]

Source§

impl<T> ArrayAdjacentPairs for [T; 30]

Source§

impl<T> ArrayAdjacentPairs for [T; 31]

Source§

impl<T> ArrayAdjacentPairs for [T; 32]

Implementors§