#tuple #elements #macro #len #limited #time

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

#93 in No standard library

Download history 20/week @ 2024-08-26 33/week @ 2024-09-02 9/week @ 2024-09-09 60/week @ 2024-09-16 13/week @ 2024-09-23 31/week @ 2024-09-30 24/week @ 2024-11-04 7/week @ 2024-11-11 2/week @ 2024-11-18 14/week @ 2024-12-02 46/week @ 2024-12-09

62 downloads per month
Used in 4 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