Skip to main content

table_len

Function table_len 

Source
pub const fn table_len<T>(groups: &[&[T]]) -> usize
Expand description

How many entries a group of tables holds in total.

The length for concat_flags and concat_args, which need it as a const generic — so it has to be computable separately from the concatenation itself.

use usage_argv::{table_len, Flag};

static A: Flag = Flag { name: "a", ..Flag::BOOL };
static B: Flag = Flag { name: "b", ..Flag::BOOL };
const GROUPS: &[&[&Flag]] = &[&[&A], &[], &[&B]];
const N: usize = table_len(GROUPS);
assert_eq!(N, 2);