[]Trait librelic::prelude::blake2::crypto_mac::generic_array::sequence::Shorten

pub unsafe trait Shorten<T>: GenericSequence<T> {
    type Shorter: Lengthen<T>;
    pub fn pop_back(self) -> (Self::Shorter, T);
pub fn pop_front(self) -> (T, Self::Shorter); }

Defines a GenericSequence which can be shortened by removing the first or last element from it.

Additionally, any shortened sequence can be lengthened by appending or prepending an element to it.

Associated Types

type Shorter: Lengthen<T>

GenericSequence that has one less element than Self

Loading content...

Required methods

pub fn pop_back(self) -> (Self::Shorter, T)

Returns a new array without the last element, and the last element.

Example:

let a = arr![i32; 1, 2, 3, 4];

let (init, last) = a.pop_back();

assert_eq!(init, arr![i32; 1, 2, 3]);
assert_eq!(last, 4);

pub fn pop_front(self) -> (T, Self::Shorter)

Returns a new array without the first element, and the first element. Example:

let a = arr![i32; 1, 2, 3, 4];

let (head, tail) = a.pop_front();

assert_eq!(head, 1);
assert_eq!(tail, arr![i32; 2, 3, 4]);
Loading content...

Implementors

impl<T, N> Shorten<T> for GenericArray<T, N> where
    N: ArrayLength<T> + Sub<B1>,
    <N as Sub<B1>>::Output: ArrayLength<T>,
    <N as Sub<B1>>::Output: Add<B1>,
    <<N as Sub<B1>>::Output as Add<B1>>::Output: ArrayLength<T>,
    <<N as Sub<B1>>::Output as Add<B1>>::Output == N, 

type Shorter = GenericArray<T, <N as Sub<B1>>::Output>

Loading content...