Function powerset

Source
pub fn powerset<T: Ord + Clone>(
    elements: impl IntoIterator<Item = T>,
) -> Combinations<T> 
Expand description

Returns the powerset of the elements in the given iterable.

§Examples

use combinatorial::powerset;

let mut subsets = powerset(vec!['x', 'y']);
assert_eq!(subsets.next(), Some(Vec::new()));
assert_eq!(subsets.next(), Some(vec!['x']));
assert_eq!(subsets.next(), Some(vec!['y']));
assert_eq!(subsets.next(), Some(vec!['x', 'y']));
assert_eq!(subsets.next(), None);

assert_eq!(powerset(0..15).count(), 1 << 15);