Trait takuzu::Source [] [src]

pub trait Source: Read {
    fn source(&mut self) -> Result<GridSourceError> { ... }
}

The Source trait allows to use any implementor of the Read trait as an input source for the grid string format with no additional effort.

Provided Methods

Creates a Grid from a readable source.

Reads from the source until EOF, parses the data as a string, checking that the size is correct, then decodes it and returns Grid.

Errors

Returns an error if either the read failed, a character other than 0, 1, . or \n was found, or the array isn't properly sized.

Examples

let grid = match io::stdin().source() {
    Ok(grid) => grid,
    Err(err) => {
        write!(io::stderr(), "error: {}\n", err.description()).unwrap();
        return
    },
};

Implementors