tupl 0.3.0

A small library for handling Rust tuples using traits.
Documentation

Tupl

A small library for handling Rust tuples using traits.
It provides a Tuple trait implemented for tuples of arity (length) 0 to 50.

use tupl::Tuple;

let tuple = (2, 3);

// access the first & last elements of the tuple
assert_eq!(&2, tuple.head());
assert_eq!(&mut 2, tuple.head_mut());
assert_eq!(&3, tuple.tail());
assert_eq!(&mut 3, tuple.tail_mut());

let tuple = tuple.append(4); // append a new element to a tuple
assert_eq!(tuple, (2, 3, 4));

let tuple = tuple.prepend(1); // prepend a new element to a tuple
assert_eq!(tuple, (1, 2, 3, 4));

let (head, tuple) = tuple.truncate_head(); // truncate the first element of a tuple
assert_eq!((head, tuple), (1, (2, 3, 4)));

let (tuple, tail) = tuple.truncate_tail(); // truncate the last element of a tuple
assert_eq!((tuple, tail), ((2, 3), 4));