Expand description
§Tupl
A #![no_std]
crate for handling Rust tuples using traits.
It also provides traits to manipulate functions.
use tupl::{GrowableTuple, NonEmptyTuple};
let mut tuple = (1, 2);
// access the first & last elements of a tuple
*tuple.head_mut() = *tuple.head() + 1;
*tuple.tail_mut() = *tuple.tail() + 1;
assert_eq!(tuple, (2, 3));
// append an element to a tuple
let tuple = tuple.append(4);
assert_eq!(tuple, (2, 3, 4));
// prepend an element to a tuple
let tuple = tuple.prepend(1);
assert_eq!(tuple, (1, 2, 3, 4));
// truncate the first element of a tuple
let (head, tuple) = tuple.truncate_head();
assert_eq!((head, tuple), (1, (2, 3, 4)));
// truncate the last element of a tuple
let (tuple, tail) = tuple.truncate_tail();
assert_eq!((tuple, tail), ((2, 3), 4));
Modules§
- fns
- Function related traits.
Traits§
- DynTuple
- Tuples of unknown size. Implemented for tuples of arity 0 to 32.
- Growable
Tuple - Tuples that can grow. Implemented for sized tuples of arity 0 to 31.
- Indexable
Tuple - Tuples that can be indexed. Implemented for sized tuples of arity 1 to 32.
- Joinable
Tuple - Tuples that can be joined together. Implemented for tuples of arity 0 to 32.
- NonEmpty
Tuple - Tuples that are not empty. Implemented for sized tuples of arity 1 to 32.
- NonUnary
Tuple - Tuples that not unary nor empty. Implemented for sized tuples of arity 2 to 32.
- Tuple
- Tuples with a known size. Implemented for sized tuples of arity 0 to 32.
Type Aliases§
- Tuple
Index - Get the type at a given index of tuple
T
.