[−][src]Crate lisbeth_tuple_tools
Some tools to manipulate tuples.
Most traits in this crate are implemented for tuples with an arity inferior or equal to eight.
TupleAppend
There is no simple way to append a value of type C
to a tuple of type
(A, B)
in rust. This is permitted by TupleAppend
.
Example
Here, we append a char
to a (char, u32)
:
use lisbeth_tuple_tools::TupleAppend; let tup = ('l', 42).append('s'); assert_eq!(tup, ('l', 42, 's'));
TupleMap*
This crate contains TupleMap1
, TupleMap2
, and so on. These traits
provide functions that allow to map a single element of a tuple from one
type to an other.
Example
The following example uses TupleMap1
, but it can be adapted to
any TupleMap*
trait:
use lisbeth_tuple_tools::TupleMap1; let t = ('a', 0, "foo"); let t = t.map_1(char::len_utf8); assert_eq!(t, (1, 0, "foo"));
Traits
TupleAppend | Allows to append an element at the end of a tuple. |
TupleMap1 | Allows to map the first element of a tuple to another type. |
TupleMap2 | Allows to map the second element of a tuple to another type. |
TupleMap3 | Allows to map the third element of a tuple to another type. |
TupleMap4 | Allows to map the fourth element of a tuple to another type. |
TupleMap5 | Allows to map the difth element of a tuple to another type. |
TupleMap6 | Allows to map the sixth element of a tuple to another type. |
TupleMap7 | Allows to map the seventh element of a tuple to another type. |
TupleMap8 | Allows to map the eighth element of a tuple to another type. |