Struct System

Source
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.

This is thread safe, and is Sync and Send.

Implementations§

Source§

impl System

Source

pub fn new() -> Self

Source

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");
Source

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();
Source

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.

Source

pub fn derive( &self, string: ProductionString, settings: RunSettings, ) -> Result<ProductionString>

Source

pub fn production_len(&self) -> usize

Returns the number of production rules in the system.

Source

pub fn symbol_len(&self) -> usize

Returns the number of symbols registered with the system

Trait Implementations§

Source§

impl Debug for System

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for System

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ProductionStore for System

Source§

fn add_production(&self, production: Production) -> Result<Production>

Adds a production to System

This is a thread safe operation. It registers the production and all of its symbols with the System instance.

The only error this returns is a poison error.

Source§

impl SymbolStore for System

Source§

fn get_symbol(&self, name: &str) -> Option<Symbol>

Return the symbol that represents the given term, if it exists.

Note that this does not create any new symbols to the system.

Source§

fn add_symbol(&self, name: &str) -> Result<Symbol>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V