#[non_exhaustive]pub enum BuildError {
EmptyTree,
UnclosedNodes,
UnbalancedFinish,
TokenOutsideNode,
MultipleRoots,
}Expand description
Why a Builder could not produce a tree.
The builder never panics on misuse; it records the first fault and surfaces it
from Builder::finish. Each variant names a specific imbalance between the
start_node / token / finish_node calls and what a caller should change.
§Examples
use syntax_lang::{BuildError, Builder};
// Closing a node that was never opened.
let mut b = Builder::<&str>::new();
b.finish_node();
assert_eq!(b.finish(), Err(BuildError::UnbalancedFinish));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EmptyTree
finish was called before any node was started, so
there is no tree to return. Start a root node before finishing.
UnclosedNodes
finish was called while nodes were still open. Balance
every start_node with a
finish_node before finishing.
UnbalancedFinish
finish_node was called with no open node. Remove
the extra close, or add the missing start_node.
TokenOutsideNode
token was called before any node was started. A tree’s
root must be a node; open one before pushing tokens.
MultipleRoots
A second root node was started after the first root was already closed. A tree has exactly one root; wrap the roots in an enclosing node instead.
Trait Implementations§
Source§impl Clone for BuildError
impl Clone for BuildError
Source§fn clone(&self) -> BuildError
fn clone(&self) -> BuildError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BuildError
Source§impl Debug for BuildError
impl Debug for BuildError
Source§impl Display for BuildError
impl Display for BuildError
impl Eq for BuildError
Source§impl Error for BuildError
impl Error for BuildError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for BuildError
impl PartialEq for BuildError
Source§fn eq(&self, other: &BuildError) -> bool
fn eq(&self, other: &BuildError) -> bool
self and other values to be equal, and is used by ==.