pub struct Expression { /* private fields */ }Expand description
An Expression is comprised of any number of Terms
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn new() -> Expression
pub fn new() -> Expression
Construct a new Expression
Sourcepub fn from_parts(v: Vec<Term>) -> Expression
pub fn from_parts(v: Vec<Term>) -> Expression
Construct an Expression from Terms
Sourcepub fn remove_term(&mut self, term: &Term) -> Option<Term>
pub fn remove_term(&mut self, term: &Term) -> Option<Term>
Remove Term from Expression
If interested if Term was removed, then inspect the returned Option.
§Example
use bnf::{Expression, Term};
let mut expression = Expression::from_parts(vec![]);
let to_remove = Term::Terminal(String::from("a_terminal"));
let removed = expression.remove_term(&to_remove);
match removed {
Some(term) => println!("removed {}", term),
None => println!("term was not in expression, so could not be removed"),
}
Sourcepub fn terms_iter(&self) -> impl Iterator<Item = &Term>
pub fn terms_iter(&self) -> impl Iterator<Item = &Term>
Get iterator of Terms within Expression
Sourcepub fn terms_iter_mut(&mut self) -> impl Iterator<Item = &mut Term>
pub fn terms_iter_mut(&mut self) -> impl Iterator<Item = &mut Term>
Get mutable iterator of Terms within Expression
Trait Implementations§
Source§impl Add<&Expression> for Term
impl Add<&Expression> for Term
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§impl Add<Expression> for &Expression
impl Add<Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§impl Add<Expression> for Term
impl Add<Expression> for Term
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§impl Add<Term> for &Expression
impl Add<Term> for &Expression
Source§impl Add<Term> for Expression
impl Add<Term> for Expression
Source§impl Add for Expression
impl Add for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a duplicate 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 moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl Default for Expression
impl Default for Expression
Source§fn default() -> Expression
fn default() -> Expression
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for Expression
impl<'de> Deserialize<'de> for Expression
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Expression
impl Display for Expression
Source§impl FromStr for Expression
impl FromStr for Expression
Source§impl Hash for Expression
impl Hash for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl Serialize for Expression
impl Serialize for Expression
impl Eq for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
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