pub trait Alphabet {
type Elem;
// Required methods
fn as_slice(&self) -> &[Self::Elem];
fn as_mut_slice(&mut self) -> &mut [Self::Elem];
fn to_vec(&self) -> Vec<Self::Elem>;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn len(&self) -> usize { ... }
}
Expand description
Alphabet describes a finite set of symbols used to construct a formal language.
Ideally, the alphabet should be implemented on unit enums since each symbol can be represented as a unique variant and assigned a particular value. The values of the variants may then be used as pointers, specifiying the location of the symbol w.r.t. the alphabet.