Trait tuplez::Popable

source ·
pub trait Popable {
    type PopFrontOutput: TupleLike;
    type PopFrontElemet;
    type PopBackOutput: TupleLike;
    type PopBackElement;

    // Required methods
    fn pop(self) -> (Self::PopBackOutput, Self::PopBackElement);
    fn pop_front(self) -> (Self::PopFrontOutput, Self::PopFrontElemet);
    fn pop_back(self) -> (Self::PopBackOutput, Self::PopBackElement);
}
Expand description

The Popable trait allows popping elements from the front and back of the tuple.

The Unit type is not Popable. All Tuples are Popable.

The take() provides another way to take out elements by their type.

Required Associated Types§

source

type PopFrontOutput: TupleLike

The type of tuple generated by popping an element from the front of the tuple.

source

type PopFrontElemet

The type of the element popped from the front of the tuple.

source

type PopBackOutput: TupleLike

The type of tuple generated by popping an element from the back of the tuple.

source

type PopBackElement

The type of the element popped from the back of the tuple.

Required Methods§

source

fn pop(self) -> (Self::PopBackOutput, Self::PopBackElement)

Pop an element from the back of the tuple.

§Examples
use tuplez::*;

let tup = tuple!(1, "hello", 3.14);
let (tup2, popped) = tup.pop();
assert_eq!(tup2, tuple!(1, "hello"));
assert_eq!(popped, 3.14);
source

fn pop_front(self) -> (Self::PopFrontOutput, Self::PopFrontElemet)

Pop an element from the front of the tuple.

§Examples
use tuplez::*;

let tup = tuple!(1, "hello", 3.14);
let (tup2, popped) = tup.pop_front();
assert_eq!(tup2, tuple!("hello", 3.14));
assert_eq!(popped, 1);
source

fn pop_back(self) -> (Self::PopBackOutput, Self::PopBackElement)

Pop an element from the back of the tuple. Same as pop().

Implementors§

source§

impl<First> Popable for Tuple<First, Unit>

source§

impl<First, Other> Popable for Tuple<First, Other>
where Other: Popable + TupleLike,

§

type PopFrontOutput = Other

§

type PopFrontElemet = First

§

type PopBackOutput = Tuple<First, <Other as Popable>::PopBackOutput>

§

type PopBackElement = <Other as Popable>::PopBackElement