Function parse

Source
pub fn parse(text: &str) -> Result<Vec<GameTree>, SgfParseError>
Expand description

Returns the GameTree values parsed from the provided text using default parsing options.

This function will attempt to convert non-FF[4] files to FF[4] if possible. Check out parse_with_options if you want to change the default behavior.

§Errors

If the text can’t be parsed as an SGF FF[4] collection, then an error is returned.

§Examples

use sgf_parse::{parse, GameType};

let sgf = "(;SZ[9]C[Some comment];B[de];W[fe])(;B[de];W[ff])";
let gametrees = parse(sgf).unwrap();
assert!(gametrees.len() == 2);
assert!(gametrees.iter().all(|gametree| gametree.gametype() == GameType::Go));