Trait tuplez::Rotatable

source ·
pub trait Rotatable {
    type RotLeftOutput: TupleLike;
    type RotRightOutput: TupleLike;

    // Required methods
    fn rot_l(self) -> Self::RotLeftOutput;
    fn rot_r(self) -> Self::RotRightOutput;
}
Expand description

The Rotatable trait allows you to rotate the elements of the tuple.

In fact, all tuples implement Rotatable, including Unit. However, implementing right rotation for Tuples relies on pop(), so this trait cannot be incorporated into TupleLike elegantly.

Required Associated Types§

source

type RotLeftOutput: TupleLike

The type of tuple generated by left rorating the elements of the tuple.

source

type RotRightOutput: TupleLike

The type of tuple generated by right rotating the elements of the tuple.

Required Methods§

source

fn rot_l(self) -> Self::RotLeftOutput

Left rotates the elements of the tuple.

§Examples
use tuplez::*;

let tup = tuple!(1, "2", 3.0, 4);
let tup2 = tup.rot_l();
assert_eq!(tup2, tuple!("2", 3.0, 4, 1));
source

fn rot_r(self) -> Self::RotRightOutput

Right rotates the elements of the tuple.

§Examples
use tuplez::*;

let tup = tuple!(1, "2", 3.0, 4);
let tup2 = tup.rot_r();
assert_eq!(tup2, tuple!(4, 1, "2", 3.0));

Implementors§

source§

impl Rotatable for Unit

source§

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

§

type RotLeftOutput = <Other as TupleLike>::PushBackOutput<First>

§

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