lindenmayer_system/
lib.rs

1pub mod parametric;
2
3use std::fmt::Debug;
4
5/// Used to name symbols and variables.
6pub trait Alphabet: Debug + PartialEq + Eq + Clone {}
7
8impl Alphabet for &'static str {}
9impl Alphabet for char {}
10impl Alphabet for u8 {}
11impl Alphabet for u16 {}
12impl Alphabet for u32 {}
13impl Alphabet for u64 {}
14impl Alphabet for usize {}
15
16/// An alphabet that distinguishes between terminal
17/// and non-terminal symbols.
18pub trait DualAlphabet: Alphabet {
19    type Terminal;
20    type NonTerminal: PartialOrd + Ord + Clone;
21
22    /// If the character is a non-terminal, return Some(..). Otherwise return None.
23    fn nonterminal(&self) -> Option<&Self::NonTerminal>;
24
25    /// If the character is a terminal, return Some(..). Otherwise return None.
26    fn terminal(&self) -> Option<&Self::Terminal>;
27}