#tuple #elements #len #macro

no-std tuple_len

Get the number of elements in a tuple

6 releases (stable)

3.0.0 Apr 27, 2024
2.0.0 Jan 13, 2023
1.1.0 Oct 31, 2022
1.0.0 Sep 24, 2020
0.1.1 Sep 22, 2020

#87 in No standard library

Download history 13/week @ 2024-01-22 5/week @ 2024-01-29 4/week @ 2024-02-19 20/week @ 2024-02-26 67/week @ 2024-03-04 43/week @ 2024-03-11 51/week @ 2024-03-18 63/week @ 2024-03-25 25/week @ 2024-04-01 3/week @ 2024-04-08 59/week @ 2024-04-15 158/week @ 2024-04-22 47/week @ 2024-04-29

269 downloads per month
Used in 3 crates (via elephantry)

MIT license

5KB
93 lines

tuple_len

Github actions Gitlab CI

Get the number of elements in a tuple.

Usage

Add it to your dependencies:

cargo add tuple_len
// The macro way, compute at compilation time
assert_eq!(tuple_len::tuple_len!(("hello", 5, 'c')), 3);

// The trait way — limited to sized 12 tuple
use tuple_len::TupleLen;
assert_eq!(().len(), 0);

// The function way — idem
let tuple = (1,);
assert_eq!(tuple_len::len(&tuple), 1);

No runtime deps