pub struct Node { /* private fields */ }Expand description
High-level type representing any node.
Wraps a NodeInner.
Implementations§
Methods from Deref<Target = NodeInner>§
Sourcepub fn as_const(&self) -> Option<&Const>
pub fn as_const(&self) -> Option<&Const>
Returns a ref to the inner Const if this node is that variant.
Sourcepub fn as_unary(&self) -> Option<&Unary>
pub fn as_unary(&self) -> Option<&Unary>
Returns a ref to the inner Unary if this node is that variant.
Sourcepub fn as_binary(&self) -> Option<&Binary>
pub fn as_binary(&self) -> Option<&Binary>
Returns a ref to the inner Binary if this node is that variant.
Sourcepub fn as_var(&self) -> Option<&Var>
pub fn as_var(&self) -> Option<&Var>
Returns a ref to the inner Var if this node is that variant.
Sourcepub fn pretty_str(&self, parent_precedence: Option<usize>) -> String
pub fn pretty_str(&self, parent_precedence: Option<usize>) -> String
Returns a neatly-formatted string representation of the AST.
Trait Implementations§
Source§impl AstNode for Node
impl AstNode for Node
Source§fn descendant_types(&self) -> impl Iterator<Item = Option<Ty>>
fn descendant_types(&self) -> impl Iterator<Item = Option<Ty>>
Returns the types of the operands of this node.
Source§fn finite_eval<C: EvalContext>(&self, ctx: &C) -> Result<TyValue, EvalError>
fn finite_eval<C: EvalContext>(&self, ctx: &C) -> Result<TyValue, EvalError>
Attempts to evaluate the AST to a single finite value.
Source§fn eval<C: EvalContext>(
&self,
ctx: &C,
) -> Result<Box<dyn Iterator<Item = Result<TyValue, EvalError>> + '_>, EvalError>
fn eval<C: EvalContext>( &self, ctx: &C, ) -> Result<Box<dyn Iterator<Item = Result<TyValue, EvalError>> + '_>, EvalError>
Evaluates all possible values of the AST.
Source§fn eval_interval<C: EvalContextInterval>(
&self,
ctx: &C,
) -> Result<Box<dyn Iterator<Item = Result<(TyValue, TyValue), EvalError>> + '_>, EvalError>
fn eval_interval<C: EvalContextInterval>( &self, ctx: &C, ) -> Result<Box<dyn Iterator<Item = Result<(TyValue, TyValue), EvalError>> + '_>, EvalError>
Interval variant of AstNode::eval.
Source§fn walk(&self, depth_first: bool, cb: &mut impl FnMut(&NodeInner) -> bool)
fn walk(&self, depth_first: bool, cb: &mut impl FnMut(&NodeInner) -> bool)
Recursively executes the given function on every node in the AST.
The walk will end early if the given function returns false and
the invocation was not depth first.
Source§fn walk_mut(
&mut self,
depth_first: bool,
cb: &mut impl FnMut(&mut NodeInner) -> bool,
)
fn walk_mut( &mut self, depth_first: bool, cb: &mut impl FnMut(&mut NodeInner) -> bool, )
Recursively executes the given function on every node in the AST.
The walk will end early if the given function returns false and
the invocation was not depth first.
Source§fn iter_children(&self) -> impl Iterator<Item = &NodeInner>
fn iter_children(&self) -> impl Iterator<Item = &NodeInner>
Iterates through the child nodes of this node.
Source§fn get<I: Iterator<Item = usize>>(&self, i: I) -> Option<&NodeInner>
fn get<I: Iterator<Item = usize>>(&self, i: I) -> Option<&NodeInner>
Returns the nested child described by the given sequence. Read more
impl Eq for Node
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more