lisbeth_tuple_tools/
lib.rs

1//! Some tools to manipulate tuples.
2//!
3//! Most traits in this crate are implemented for tuples with an arity inferior
4//! or equal to eight.
5//!
6//! # `TupleAppend`
7//!
8//! There is no simple way to append a value of type `C` to a tuple of type
9//! `(A, B)` in rust. This is permitted by [`TupleAppend`].
10//!
11//! ## Example
12//!
13//! Here, we append a [`char`] to a `(char, u32)`:
14//!
15//! ```rust
16//! use lisbeth_tuple_tools::TupleAppend;
17//!
18//! let tup = ('l', 42).append('s');
19//!
20//! assert_eq!(tup, ('l', 42, 's'));
21//! ```
22//!
23//! # `TupleMap*`
24//!
25//! This crate contains [`TupleMap1`], [`TupleMap2`], and so on. These traits
26//! provide functions that allow to map a single element of a tuple from one
27//! type to an other.
28//!
29//! ## Example
30//!
31//! The following example uses [`TupleMap1`], but it can be adapted to
32//! any `TupleMap*` trait:
33//!
34//! ```rust
35//! use lisbeth_tuple_tools::TupleMap1;
36//!
37//! let t = ('a', 0, "foo");
38//! let t = t.map_1(char::len_utf8);
39//!
40//! assert_eq!(t, (1, 0, "foo"));
41//! ```
42
43mod append;
44mod map;
45
46pub use append::TupleAppend;
47pub use map::*;