pub struct NamedRule<F: Clone> { /* private fields */ }Expand description
We can create a rule using this struct and pass it into our list of rules directly,
For debugging and tracing, it is helpful to see rules by a meaningful name.
or we can make use of the named_rule macro (see [tree-morph-macros]).
This struct and macro is for the short form way of defining named rules. You can change the name
of the rule by implementing the Rule trait as well.
use tree_morph::prelude::*;
use tree_morph_macros::named_rule;
use uniplate::Uniplate;
#[derive(Debug, Clone, PartialEq, Eq, Uniplate)]
#[uniplate()]
enum Expr {
// Snip
}
struct Meta;
#[named_rule("CustomName")]
fn my_rule(_: &mut Commands<Expr, Meta>, expr: &Expr, _: &Meta) -> Option<Expr> {
/// rule implementation
}This macro will return a helper function called my_rule which returns the NamedRule for us to
use. We can add this to our list of rules with vec![my_rule].
If a name is not specified, the functions name will be it’s identifier.
Implementations§
Trait Implementations§
Source§impl<T, M, F> Rule<T, M> for NamedRule<F>
impl<T, M, F> Rule<T, M> for NamedRule<F>
Auto Trait Implementations§
impl<F> Freeze for NamedRule<F>where
F: Freeze,
impl<F> RefUnwindSafe for NamedRule<F>where
F: RefUnwindSafe,
impl<F> Send for NamedRule<F>where
F: Send,
impl<F> Sync for NamedRule<F>where
F: Sync,
impl<F> Unpin for NamedRule<F>where
F: Unpin,
impl<F> UnsafeUnpin for NamedRule<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for NamedRule<F>where
F: UnwindSafe,
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
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>
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>
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: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.