[][src]Trait alphabet::WordIterable

pub trait WordIterable {
    fn iter_words(&self) -> WordIterator<'_>;
}

Allows to iterate over words of an alphabet (i.e. A* for some alphabet A). This is an infinite iterator.

The words are sorted lexicographically if the alphabet imposes any particular order on its symbols.

Note: All alphabets generated by the alphabet!() macro impose an order on their symbols, namely the order in which they were specified in the alphabet contents.

Examples

use alphabet::*;

alphabet!(BINARY = "01");
let mut words = BINARY.iter_words();
assert_eq!(words.next().unwrap(), "");
assert_eq!(words.next().unwrap(), "0");
assert_eq!(words.next().unwrap(), "1");

// Note that this does not 'count' in binary, it operates on symbols:
assert_eq!(words.next().unwrap(), "00");
assert_eq!(words.next().unwrap(), "01");
assert_eq!(words.next().unwrap(), "10");
assert_eq!(words.next().unwrap(), "11");
assert_eq!(words.next().unwrap(), "000");

Required methods

fn iter_words(&self) -> WordIterator<'_>

Obtains an infinite iterator over the words constructible from the implementor.

Examples

use alphabet::*;

alphabet!(SCREAM = "A");
let mut words = SCREAM.iter_words();
assert_eq!(words.next().unwrap(), "");
assert_eq!(words.next().unwrap(), "A");
assert_eq!(words.next().unwrap(), "AA");
assert_eq!(words.next().unwrap(), "AAA");
Loading content...

Implementations on Foreign Types

impl WordIterable for [char][src]

impl WordIterable for Vec<char>[src]

Loading content...

Implementors

Loading content...