Struct ca_formats::apgcode::ApgCode[][src]

pub struct ApgCode<'a> { /* fields omitted */ }

A parser for apgcode format.

Only supports patterns that are encoded in Extended Wechsler format, i.e., still lifes, oscillators, spaceships. Rules with more than 2 states are not yet supported.

As an iterator, it iterates over the living cells.

Reading from files is not supported, since apgcode is usually short and not stored in a file.

Example

use ca_formats::apgcode::{ApgCode, PatternType};

const GLIDER: &str = "xq4_153";

let glider = ApgCode::new(GLIDER).unwrap();
assert_eq!(glider.pattern_type(), PatternType::Spaceship);
assert_eq!(glider.period(), 4);

let cells = glider.map(|cell| cell.unwrap()).collect::<Vec<_>>();
assert_eq!(cells, vec![(0, 0), (1, 0), (1, 2), (2, 0), (2, 1)]);

Implementations

impl<'a> ApgCode<'a>[src]

pub fn new(string: &'a str) -> Result<Self, Error>[src]

Creates a new parser instance from a string.

pub fn period(&self) -> u64[src]

Period of the pattern.

pub fn pattern_type(&self) -> PatternType[src]

Type of the pattern.

Trait Implementations

impl<'a> Clone for ApgCode<'a>[src]

impl<'a> Debug for ApgCode<'a>[src]

impl<'a> Iterator for ApgCode<'a>[src]

An iterator over living cells in an apgcode string.

type Item = Result<Coordinates, Error>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for ApgCode<'a>

impl<'a> Send for ApgCode<'a>

impl<'a> Sync for ApgCode<'a>

impl<'a> Unpin for ApgCode<'a>

impl<'a> UnwindSafe for ApgCode<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.