Expand description
§Tuplify
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.
Macros§
- HCons
- Constructs an
HCons
type. - count_
tokens - Helper macro that counts the number of tokens passed to it.
- hcons
- Constructs an
HCons
value. - hcons_
pat - Constructs a pattern matching
HCons
values.
Structs§
Enums§
Traits§
- AsMuts
- Turns a mutable reference into an heterogeneous list of mutable references.
- AsRefs
- Turns a reference to an heterogenous list into a list of references.
- Extend
- Concatenate 2 heterogenous lists, extending self with
Other
- Fun
- Helper trait to use heterogenous lists as arguments for
Fn
s. - FunMut
- Helper trait to use heterogenous lists as arguments for
FnMut
s. - FunOnce
- Helper trait to use heterogenous lists as arguments for
FnOnce
s. - HList
- Heterogenous fixed size (aka: compile time) list.
- IntoH
Cons - Trait for converting a heterogeneous list into a
HCons
list. - Into
Opts - Trait for wrapping each element of an heterogenous list in
Some
. - Into
Tuple - Utility trait used to convert something into a
crate::Tuple
. - PopBack
- Removes the element at the back of the list
- PopBack
Ext - Removes the element at the back of the list
- Push
Back - Adds an element at the end of the list
- Push
Front - Adds an element at the begining of the list
- Reverse
- Reversible heterogeneous list.
- TryPop
Back - Removes the element at the back of the list
- TryUncons
- Removes the list front element if the list is empty, returns None
- TryValidate
Opt - Try to convert a list of
Some
s to a list of the inner values. - TryValidate
Res - Trait used for the conversion of a list of
Ok
s to a list of the inner values. - Tuple
- Identifier for tuple types
- Uncons
- Removes the list front element
- Uncons
Ext - Extension trait for types implementing
Uncons
. - Uncons
Opt - Removes the list front element.
- Unpack
- Unpacks heterogeneous lists containing exactly one element.
- Validate
Opt - Convert a list of
Option
s to an option of the inner elements. - Validate
Res - Convert a list of
Result
s to an option of the inner elements.