| Crates.io | tuple-arity |
| lib.rs | tuple-arity |
| version | 0.1.2 |
| created_at | 2020-08-13 01:40:55.609728+00 |
| updated_at | 2020-08-13 01:44:59.881496+00 |
| description | Get the arity (number of elements) of tuple types with 0-12 elements |
| homepage | |
| repository | https://github.com/TheBerkin/tuple-arity |
| max_upload_size | |
| id | 276001 |
| size | 5,327 |
A simple crate for getting the arity (number of elements) of tuple types with 0 to 12 elements.
You can use the tuple_arity() function to get the arity of an existing tuple value.
use tuple_arity::*;
assert_eq!(0, tuple_arity(&()));
assert_eq!(1, tuple_arity(&("foo",)));
assert_eq!(2, tuple_arity(&("foo", "bar")));
assert_eq!(3, tuple_arity(&("foo", "bar", "baz")));
You can also use the Arity trait to get the arity of a tuple type directly:
use tuple_arity::Arity;
assert_eq!(0, <()>::arity());
assert_eq!(1, <(u8,)>::arity());
assert_eq!(2, <(u8, u8)>::arity());
assert_eq!(3, <(u8, u8, u8)>::arity());
assert_eq!(4, <(u8, u8, u8, u8)>::arity());