inc_selector

Function inc_selector 

Source
pub fn inc_selector(v: &mut [bool]) -> bool
Expand description

Increments a “selector” slice of booleans. Essentially treats the slice as a binary number and increments it. Returns true if the input is already all true and doesn’t increment. Returns false and increments otherwise.

use aoclib_rs::inc_selector;

let mut v = [true, false, false, true, true];
assert_eq!(inc_selector(&mut v), false);
assert_eq!(v, [true, false, true, false, false]);

let mut v = [true, true, true, true, true];
assert_eq!(inc_selector(&mut v), true);
assert_eq!(v, [true, true, true, true, true]);