pub enum GameTree {
GoGame(SgfNode<Prop>),
Unknown(SgfNode<Prop>),
}
Expand description
An SGF GameTree value.
This type allows creating a collection of SgfNode
values for different games. This is
used in the return type of the parse
function. Users of the
serialize
function will need to build these.
For now, all non-Go games will parse as GameTree::Unknown
which should also be used for any
serialization of non-Go games.
Variants§
Implementations§
Source§impl GameTree
impl GameTree
Sourcepub fn into_go_node(self) -> Result<SgfNode<Prop>, SgfParseError>
pub fn into_go_node(self) -> Result<SgfNode<Prop>, SgfParseError>
Consumes a Go game GameTree
and returns the contained SgfNode
.
This is a convenience method for go games.
§Errors
Returns an error if the variant isn’t a GameTree::GoGame
.
§Examples
use sgf_parse::parse;
let gametree = parse("(;B[de]C[A comment])").unwrap().into_iter().next().unwrap();
let sgf_node = gametree.into_go_node().unwrap();
Sourcepub fn as_go_node(&self) -> Result<&SgfNode<Prop>, SgfParseError>
pub fn as_go_node(&self) -> Result<&SgfNode<Prop>, SgfParseError>
Return a reference to the root SgfNode
of the tree.
This is a convenience method for go games.
§Errors
Returns an error if the variant isn’t a GameTree::GoGame
.
§Examples
use sgf_parse::parse;
let gametrees = parse("(;B[de]C[A comment])").unwrap();
let sgf_node = gametrees.first().unwrap().as_go_node().unwrap();
Trait Implementations§
impl StructuralPartialEq for GameTree
Auto Trait Implementations§
impl Freeze for GameTree
impl RefUnwindSafe for GameTree
impl Send for GameTree
impl Sync for GameTree
impl Unpin for GameTree
impl UnwindSafe for GameTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more