Struct sise::NodeReadUtil
source · pub struct NodeReadUtil<'a, 'b> { /* private fields */ }
Expand description
Utility to read nodes.
See as_atom
and as_list
methods.
Implementations§
source§impl<'a, 'b> NodeReadUtil<'a, 'b>
impl<'a, 'b> NodeReadUtil<'a, 'b>
pub fn new(node: &'a Node, pos_tree: Option<&'b PosTree>) -> Self
sourcepub fn pos_tree(&self) -> Option<&'b PosTree>
pub fn pos_tree(&self) -> Option<&'b PosTree>
Returns the position tree of the node in this utility.
sourcepub fn as_atom(&self) -> Result<AtomNodeReadUtil<'a>, ReadUtilError>
pub fn as_atom(&self) -> Result<AtomNodeReadUtil<'a>, ReadUtilError>
If the node is an atom, returns a AtomNodeReadUtil
with such
atom. Otherwise, it returns a ReadError::ExpectedAtom
error.
Example
use sise::sise_expr;
let node = sise_expr!("example");
let node_read_util = sise::NodeReadUtil::new(&node, None);
assert_eq!(node_read_util.as_atom().unwrap().atom(), "example");
sourcepub fn as_list(&self) -> Result<ListNodeReadUtil<'a, 'b>, ReadUtilError>
pub fn as_list(&self) -> Result<ListNodeReadUtil<'a, 'b>, ReadUtilError>
If the node is a list, returns a ListNodeReadUtil
with such
list. Otherwise, it returns a ReadError::ExpectedList
error.
Example
use sise::sise_expr;
let node = sise_expr!(["example"]);
let node_read_util = sise::NodeReadUtil::new(&node, None);
assert_eq!(node_read_util.as_list().unwrap().list(), [sise_expr!("example")]);
Trait Implementations§
source§impl<'a, 'b> Clone for NodeReadUtil<'a, 'b>
impl<'a, 'b> Clone for NodeReadUtil<'a, 'b>
source§fn clone(&self) -> NodeReadUtil<'a, 'b>
fn clone(&self) -> NodeReadUtil<'a, 'b>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more