tuplify

Crates.iotuplify
lib.rstuplify
version1.1.4
sourcesrc
created_at2023-04-08 09:51:47.366089
updated_at2023-05-03 13:25:15.820972
descriptionGeneric hlist/tuple library
homepagehttps://github.com/cantina-space/tuplify
repositoryhttps://github.com/cantina-space/tuplify
max_upload_size
id833530
size58,700
(Massou31)

documentation

https://docs.rs/tuplify

README

Tuplify

Crate link Documentation License

Utility library that facilitates the use of tuples as generic arguments.

See individual Traits for features implementation and detailled examples.

Examples

Tuples

use tuplify::*;

assert_eq!((1, 2).push_back(3), (1, 2, 3));

assert_eq!((Some(1), Some(2), Some(3)).validate(), Some((1, 2, 3)));

assert_eq!((Some(1), Some(2), None::<i32>).validate(), None);

assert_eq!((1, 2).extend((3, 4)), (1, 2, 3, 4));

assert_eq!((1, 2, 3, 4).pop_back(), (4, (1, 2, 3)));

assert_eq!((1, 2, 3, 4).uncons(), (1, (2, 3, 4)));

Heterogenous list

use tuplify::*;

assert_eq!(hcons![1, 2].push_back(3), hcons![1, 2, 3]);

assert_eq!(hcons![Some(1), Some(2), Some(3)].validate(), Some(hcons![1, 2, 3]));

assert_eq!(hcons![Ok(1), Ok(2), Err::<u32, _>("oh no")].validate(), Err("oh no"));

assert_eq!(hcons![1, 2].extend(hcons![3, 4]), hcons![1, 2, 3, 4]);

assert_eq!(hcons![1, 2, 3, 4].pop_back(), (4, hcons![1, 2, 3]));

assert_eq!(hcons![1, 2, 3, 4].uncons(), (1, hcons![2, 3, 4]));

Contribution

Found a problem or have a suggestion? Feel free to open an issue.

Commit count: 7

cargo fmt