tuple-arity 0.1.2

Get the arity (number of elements) of tuple types with 0-12 elements
Documentation
  • Coverage
  • 75%
    3 out of 4 items documented2 out of 3 items with examples
  • Size
  • Source code size: 4.95 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.22 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • TheBerkin/tuple-arity
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TheBerkin

tuple-arity

Crates.io Crates.io Docs.rs shield

A simple crate for getting the arity (number of elements) of tuple types with 0 to 12 elements.

How to use

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());