#tuple #elements #len #macro

无std tuple_len

获取元组中元素的数量

6 个版本 (稳定)

3.0.0 2024年4月27日
2.0.0 2023年1月13日
1.1.0 2022年10月31日
1.0.0 2020年9月24日
0.1.1 2020年9月22日

88无标准库 中排名

Download history 173/week @ 2024-04-26 10/week @ 2024-05-03 4/week @ 2024-05-24 6/week @ 2024-05-31 1/week @ 2024-06-07 1/week @ 2024-06-14 35/week @ 2024-06-21 4/week @ 2024-06-28 5/week @ 2024-07-12 44/week @ 2024-07-19 15/week @ 2024-07-26 1/week @ 2024-08-09

61 每月下载量
3 个 Crates 中使用(通过 elephantry

MIT 许可证

5KB
93

tuple_len

Github actions Gitlab CI

获取元组中元素的数量。

用法

将其添加到您的依赖中

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

无运行时依赖