pub struct System { /* private fields */ }
Expand description
Represents an L-system. This is the base for running the production rules.
This struct is convenient for defining and storing symbols and productions without having to create your own collections.
See the system namespace to for information more broadly.
- Productions can be parsed via strings.
- Productions can be programmatically created.
Implementations§
Source§impl System
impl System
pub fn new() -> Self
Sourcepub fn of_family<F: TryIntoFamily>(family: F) -> Result<Self>
pub fn of_family<F: TryIntoFamily>(family: F) -> Result<Self>
Given a previously defined family, this returns a new system using the defined symbols / alphabet / words of that family of systems.
use rusty_systems::system::{family, System};
use rusty_systems::interpretation::abop;
family::register(abop::abop_family()).expect("Unable to register the family");
let system = System::of_family("ABOP").expect("Unable to find system");
Sourcepub fn parse_production(&self, production: &str) -> Result<Production>
pub fn parse_production(&self, production: &str) -> Result<Production>
Parse a string as a production and add it to the system.
This is essentially equivalent to:
use rusty_systems::parser::parse_production;
let production = parse_production("A -> B C").unwrap();
system.add_production(production).unwrap();
Sourcepub fn derive_once(&self, string: ProductionString) -> Result<ProductionString>
pub fn derive_once(&self, string: ProductionString) -> Result<ProductionString>
Run a single iteration of the productions on the given string.
Returns None
if an empty string is produced.
pub fn derive( &self, string: ProductionString, settings: RunSettings, ) -> Result<ProductionString>
Sourcepub fn production_len(&self) -> usize
pub fn production_len(&self) -> usize
Returns the number of production rules in the system.
Sourcepub fn symbol_len(&self) -> usize
pub fn symbol_len(&self) -> usize
Returns the number of symbols registered with the system
Trait Implementations§
Source§impl ProductionStore for System
impl ProductionStore for System
Source§fn add_production(&self, production: Production) -> Result<Production>
fn add_production(&self, production: Production) -> Result<Production>
Auto Trait Implementations§
impl !Freeze for System
impl RefUnwindSafe for System
impl Send for System
impl Sync for System
impl Unpin for System
impl UnwindSafe for System
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more