pub trait ArrayAdjacentPairs {
    type T;
    type AdjacentPairs;

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

Required Associated Types

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

Required Methods

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

Implementors