Uses old Rust 2015
0.1.1 |
|
---|
#5 in #lindenmayer
16KB
182 lines
Introduction
This project aims to provide a simple interface for working with L-systems in the Rust programming language.
Examples
let mut system: LSystem<&Fn(&Vec<String>) -> String> = LSystem::with_axiom("b");
system.add_rule('a', "ab");
system.add_rule('b', "a");
assert_eq!(system.next().unwrap(), "b");
assert_eq!(system.next().unwrap(), "a");
assert_eq!(system.next().unwrap(), "ab");
assert_eq!(system.next().unwrap(), "aba");
assert_eq!(system.next().unwrap(), "abaab");
assert_eq!(system.next().unwrap(), "abaababa");
let mut system: LSystem<&Fn(&Vec<String>) -> String> = LSystem::with_axiom("baaaaaaa");
system.add_rule('b', "a");
system.add_context_rule((Some("b"), 'a', None), "b");
assert_eq!(system.next().unwrap(), "baaaaaaa");
assert_eq!(system.next().unwrap(), "abaaaaaa");
assert_eq!(system.next().unwrap(), "aabaaaaa");
assert_eq!(system.next().unwrap(), "aaabaaaa");
assert_eq!(system.next().unwrap(), "aaaabaaa");
assert_eq!(system.next().unwrap(), "aaaaabaa");
assert_eq!(system.next().unwrap(), "aaaaaaba");
assert_eq!(system.next().unwrap(), "aaaaaaab");
assert_eq!(system.next().unwrap(), "aaaaaaaa");
Dependencies
~330–560KB