count

Function count 

Source
pub const fn count(n: usize) -> Option<usize>
Expand description

Returns Some with the number of combinations that n variables produces.

Returns None if n variables would produce more than what can be represented.

  • 1 variable produces 2 combinations
  • 2 variables produces 4 combinations
  • 3 variables produces 8 combinations
  • 4 variables produces 16 combinations
  • MAX variables produces count(MAX) combinations

Use is_supported(n) or count(n).is_some() to check if n variables is supported.

  • 15 variables is supported on 16-bit targets
  • 31 variables is supported on 32-bit targets
  • 63 variables is supported on 64-bit targets

See warning notice in crate root.

ยงExample

assert_eq!(count(0), Some(0));

assert_eq!(count(1), Some(2));
assert_eq!(count(2), Some(4));
assert_eq!(count(3), Some(8));
assert_eq!(count(4), Some(16));
assert_eq!(count(5), Some(32));
assert_eq!(count(6), Some(64));
assert_eq!(count(7), Some(128));
assert_eq!(count(8), Some(256));
assert_eq!(count(9), Some(512));
assert_eq!(count(10), Some(1024));
assert_eq!(count(11), Some(2048));
assert_eq!(count(12), Some(4096));
assert_eq!(count(13), Some(8192));
assert_eq!(count(14), Some(16384));

assert_eq!(count(100), None);