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

fn source(&mut self) -> Result<GridSourceError>

Creates a Grid from a readable source. Reads from the source until EOF, parses the data as a string, then checks the array for size and legality and converts it to a Grid

Failure

Returns an error if either the read failed, a character other than 0, 1, . or \n was found, or the if the array is invalid or illegal. If the read was successful and no unexpected character was found, the faulty array is returned as well.

Examples

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

Implementors