pub struct Rule<'a> {
pub name: &'a str,
pub application: fn(&Expression, &SymbolTable) -> Result<Reduction, ApplicationError>,
pub rule_sets: &'a [(&'a str, u16)],
}Expand description
A rule with a name, application function, and rule sets.
§Fields
nameThe name of the rule.applicationThe function to apply the rule.rule_setsA list of rule set names and priorities that this rule is a part of. This is used to populate rulesets at runtime.
Fields§
§name: &'a str§application: fn(&Expression, &SymbolTable) -> Result<Reduction, ApplicationError>§rule_sets: &'a [(&'a str, u16)]Implementations§
Source§impl<'a> Rule<'a>
impl<'a> Rule<'a>
pub const fn new( name: &'a str, application: fn(&Expression, &SymbolTable) -> Result<Reduction, ApplicationError>, rule_sets: &'a [(&'static str, u16)], ) -> Rule<'a>
pub fn apply( &self, expr: &Expression, symbols: &SymbolTable, ) -> Result<Reduction, ApplicationError>
Trait Implementations§
Source§impl Rule<Expression, SymbolTable> for &Rule<'_>
impl Rule<Expression, SymbolTable> for &Rule<'_>
Source§fn apply(
&self,
commands: &mut Commands<Expression, SymbolTable>,
subtree: &Expression,
meta: &SymbolTable,
) -> Option<Expression>
fn apply( &self, commands: &mut Commands<Expression, SymbolTable>, subtree: &Expression, meta: &SymbolTable, ) -> Option<Expression>
Applies the rule to the given subtree and returns the result if applicable. Read more
Source§impl Rule<Expression, SymbolTable> for Rule<'_>
impl Rule<Expression, SymbolTable> for Rule<'_>
Source§fn apply(
&self,
commands: &mut Commands<Expression, SymbolTable>,
subtree: &Expression,
meta: &SymbolTable,
) -> Option<Expression>
fn apply( &self, commands: &mut Commands<Expression, SymbolTable>, subtree: &Expression, meta: &SymbolTable, ) -> Option<Expression>
Applies the rule to the given subtree and returns the result if applicable. Read more
impl Eq for Rule<'_>
Auto Trait Implementations§
impl<'a> Freeze for Rule<'a>
impl<'a> RefUnwindSafe for Rule<'a>
impl<'a> Send for Rule<'a>
impl<'a> Sync for Rule<'a>
impl<'a> Unpin for Rule<'a>
impl<'a> UnwindSafe for Rule<'a>
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 40 bytes