[−][src]Trait ca_rules::ParseNeumannGen
A trait for parsing totalistic Generations rules with von Neumann neighborhood.
The b
/ s
data of this type of rules consists of numbers of live neighbors
that cause a cell to be born / survive.
Examples
use ca_rules::ParseNeumannGen; #[derive(Debug, Eq, PartialEq)] struct Rule { b: Vec<u8>, s: Vec<u8>, gen: usize, } impl ParseNeumannGen for Rule { fn from_bsg(b: Vec<u8>, s: Vec<u8>, gen: usize) -> Self { Rule { b, s, gen } } } let life = Rule::parse_rule("B2/S013/3V").unwrap(); assert_eq!( life, Rule { b: vec![2], s: vec![0, 1, 3], gen: 3, } )
Required methods
fn from_bsg(b: Vec<u8>, s: Vec<u8>, gen: usize) -> Self
Construct the rule from b
/ s
data and the number of states.
Provided methods
fn parse_rule(input: &str) -> Result<Self, ParseRuleError> where
Self: Sized,
Self: Sized,
The parser.