Struct ca_formats::plaintext::Plaintext[][src]

pub struct Plaintext<I: Input> { /* fields omitted */ }

A parser for Plaintext format.

As an iterator, it iterates over the living cells.

Examples

Reading from a string:

use ca_formats::plaintext::Plaintext;

const GLIDER: &str = r"! Glider
!
.O.
..O
OOO";

let glider = Plaintext::new(GLIDER).unwrap();

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

Reading from a file:

use std::fs::File;
use ca_formats::plaintext::Plaintext;

let file = File::open("tests/sirrobin.cells").unwrap();
let sirrobin = Plaintext::new_from_file(file).unwrap();

assert_eq!(sirrobin.count(), 282);

Implementations

impl<I: Input> Plaintext<I>[src]

pub fn new(input: I) -> Result<Self, Error>[src]

Creates a new parser instance from input.

impl<I, L> Plaintext<I> where
    I: Input<Lines = L>,
    L: Input
[src]

pub fn remains(self) -> Result<Plaintext<L>, Error>[src]

Parse the remaining unparsed lines as a new Plaintext.

impl<R: Read> Plaintext<BufReader<R>>[src]

pub fn new_from_file(file: R) -> Result<Self, Error>[src]

Creates a new parser instance from something that implements Read trait, e.g., a File.

Trait Implementations

impl<I: Input> Clone for Plaintext<I> where
    I::Lines: Clone,
    I::Bytes: Clone
[src]

impl<I: Debug + Input> Debug for Plaintext<I> where
    I::Lines: Debug,
    I::Bytes: Debug
[src]

impl<I: Input> Iterator for Plaintext<I>[src]

An iterator over living cells in a Plaintext file.

type Item = Result<Coordinates, Error>

The type of the elements being iterated over.

Auto Trait Implementations

impl<I> RefUnwindSafe for Plaintext<I> where
    <I as Input>::Bytes: RefUnwindSafe,
    <I as Input>::Lines: RefUnwindSafe

impl<I> Send for Plaintext<I> where
    <I as Input>::Bytes: Send,
    <I as Input>::Lines: Send

impl<I> Sync for Plaintext<I> where
    <I as Input>::Bytes: Sync,
    <I as Input>::Lines: Sync

impl<I> Unpin for Plaintext<I> where
    <I as Input>::Bytes: Unpin,
    <I as Input>::Lines: Unpin

impl<I> UnwindSafe for Plaintext<I> where
    <I as Input>::Bytes: UnwindSafe,
    <I as Input>::Lines: UnwindSafe

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.