Trait vector2math::Trio

source ·
pub trait Trio: Sized {
    type Item;

    // Required methods
    fn into_trio(self) -> (Self::Item, Self::Item, Self::Item);
    fn from_items(a: Self::Item, b: Self::Item, c: Self::Item) -> Self;

    // Provided methods
    fn pairwise<O, T, F, R>(self, other: O, ff: F) -> T
       where O: Trio,
             T: Trio<Item = R>,
             F: Fn(Self::Item, O::Item) -> R { ... }
    fn trio_iter(self) -> Chain3<Self::Item> { ... }
}
Expand description

Trait for defining a group of 3 items of the same type.

This trait is meant to generalize having three similar things. It is implemented for (T, T, T) and [T; 3] with Item = T. However, because a trio does not necessarily have to be an actual tuple It is also implemented for (T, T, T, T, T, T) and [T; 6] with Item = (T, T, T) and Item = [T; 3] respectively.

Required Associated Types§

source

type Item

The type of the trio’s item

Required Methods§

source

fn into_trio(self) -> (Self::Item, Self::Item, Self::Item)

Get the trio

source

fn from_items(a: Self::Item, b: Self::Item, c: Self::Item) -> Self

Create a trio from three items

Provided Methods§

source

fn pairwise<O, T, F, R>(self, other: O, ff: F) -> Twhere O: Trio, T: Trio<Item = R>, F: Fn(Self::Item, O::Item) -> R,

Apply a function pairwise to the items of two trios

source

fn trio_iter(self) -> Chain3<Self::Item>

Get an iterator over the trio’s items

Implementations on Foreign Types§

source§

impl<T> Trio for (T, T, T)

§

type Item = T

source§

fn into_trio(self) -> (Self::Item, Self::Item, Self::Item)

source§

fn from_items(a: Self::Item, b: Self::Item, c: Self::Item) -> Self

source§

impl<T> Trio for [T; 3]where T: Copy,

§

type Item = T

source§

fn into_trio(self) -> (Self::Item, Self::Item, Self::Item)

source§

fn from_items(a: Self::Item, b: Self::Item, c: Self::Item) -> Self

source§

impl<T> Trio for [T; 6]where T: Copy,

§

type Item = [T; 2]

source§

fn into_trio(self) -> (Self::Item, Self::Item, Self::Item)

source§

fn from_items(a: Self::Item, b: Self::Item, c: Self::Item) -> Self

source§

impl<T> Trio for (T, T, T, T, T, T)

§

type Item = (T, T)

source§

fn into_trio(self) -> (Self::Item, Self::Item, Self::Item)

source§

fn from_items(a: Self::Item, b: Self::Item, c: Self::Item) -> Self

Implementors§