Function life_backend::format::open
source · pub fn open<P>(path: P) -> Result<Box<dyn Format>>where
P: AsRef<Path>,Expand description
Attempts to open a file with the file format handler specified by the file extension.
Examples
use life_backend::format;
use life_backend::Rule;
let path = "patterns/rpentomino.cells";
let handler = format::open(path)?;
assert_eq!(handler.rule(), Rule::conways_life());
assert_eq!(handler.live_cells().count(), 5);use life_backend::format;
use life_backend::Rule;
let path = "patterns/bheptomino.rle";
let handler = format::open(path)?;
assert_eq!(handler.rule(), Rule::conways_life());
assert_eq!(handler.live_cells().count(), 7);