[−][src]Struct sgf_parse::SgfNode
A node in an SGF Game Tree.
Implementations
impl SgfNode
[src]
pub fn new(
props: Vec<SgfProp>,
children: Vec<SgfNode>,
is_root: bool
) -> Result<SgfNode, SgfParseError>
[src]
props: Vec<SgfProp>,
children: Vec<SgfNode>,
is_root: bool
) -> Result<SgfNode, SgfParseError>
pub fn get_property(&self, identifier: &str) -> Option<&SgfProp>
[src]
Returns the property with the provided identifier for the node (if present).
Examples
use sgf_parse::{parse, SgfProp}; let node = parse("(;SZ[13:13];B[de])").unwrap().into_iter().next().unwrap(); let board_size = match node.get_property("SZ") { Some(SgfProp::SZ(size)) => size.clone(), None => (19, 19), _ => unreachable!(), };
pub fn children<'a>(&'a self) -> impl Iterator<Item = &SgfNode> + 'a
[src]
Returns an iterator over the children of this node.
Examples
use sgf_parse::parse; let node = parse("(;SZ[19](;B[de])(;B[dd]HO[2]))").unwrap().into_iter().next().unwrap(); for child in node.children() { if let Some(prop) = child.get_property("HO") { println!("Found a hotspot!") } }
pub fn properties<'a>(&'a self) -> impl Iterator<Item = &SgfProp> + 'a
[src]
Returns an iterator over the properties of this node.
Examples
use sgf_parse::{parse, SgfProp, Move}; let node = parse("(;B[de]C[A comment])").unwrap().into_iter().next().unwrap(); for prop in node.properties() { match prop { SgfProp::B(mv) => match mv { Move::Move(p) => println!("B Move at {}, {}", p.x, p.y), Move::Pass => println!("B Pass"), } SgfProp::W(mv) => match mv { Move::Move(p) => println!("W Move at {}, {}", p.x, p.y), Move::Pass => println!("W Pass"), } _ => {}, } }
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for SgfNode
impl Send for SgfNode
impl Sync for SgfNode
impl Unpin for SgfNode
impl UnwindSafe for SgfNode
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,