#element

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

#187 in No standard library

Download history 48/week @ 2025-09-18 109/week @ 2025-09-25 21/week @ 2025-10-02 13/week @ 2025-10-09 39/week @ 2025-10-16 130/week @ 2025-10-23 32/week @ 2025-10-30 26/week @ 2025-11-06 17/week @ 2025-11-13 14/week @ 2025-11-20 25/week @ 2025-11-27 56/week @ 2025-12-04 3/week @ 2025-12-11 59/week @ 2025-12-18 7/week @ 2025-12-25 51/week @ 2026-01-01

120 downloads per month
Used in 5 crates (2 directly)

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