[][src]Trait exprz::Expression

pub trait Expression: Into<Expr<Self>> {
    type Atom;
    type Group: IntoIteratorGen<Self>;
    fn cases(&self) -> ExprRef<'_, Self>;
fn from_atom(atom: Self::Atom) -> Self;
fn from_group(group: Self::Group) -> Self; #[must_use] fn from_expr(expr: Expr<Self>) -> Self { ... }
fn from_str(s: &str) -> Result<Self, Error>
    where
        Self::Atom: FromIterator<char>,
        Self::Group: FromIterator<Self>
, { ... }
#[must_use] fn is_atom(&self) -> bool { ... }
#[must_use] fn is_group(&self) -> bool { ... }
#[must_use] fn atom(self) -> Option<Self::Atom> { ... }
#[must_use] fn group(self) -> Option<Self::Group> { ... }
fn unwrap_atom(self) -> Self::Atom { ... }
fn unwrap_group(self) -> Self::Group { ... }
fn empty_atom<T>() -> Self
    where
        Self::Atom: FromIterator<T>
, { ... }
fn empty_group() -> Self
    where
        Self::Group: FromIterator<Self>
, { ... }
fn default() -> Self
    where
        Self::Group: FromIterator<Self>
, { ... }
fn clone(&self) -> Self
    where
        Self::Atom: Clone,
        Self::Group: FromIterator<Self>
, { ... }
fn eq<E>(&self, other: &E) -> bool
    where
        E: Expression,
        Self::Atom: PartialEq<<E as Expression>::Atom>
, { ... }
fn is_subexpression<E>(&self, other: &E) -> bool
    where
        E: Expression,
        Self::Atom: PartialEq<<E as Expression>::Atom>
, { ... }
fn map<E, F>(self, f: F) -> E
    where
        E: Expression,
        F: FnMut(Self::Atom) -> <E as Expression>::Atom,
        Self::Group: IntoIterator,
        <E as Expression>::Group: FromIterator<E>,
        <Self::Group as IntoIterator>::Item == Self
, { ... }
fn map_ref<E, F>(&self, f: F) -> E
    where
        E: Expression,
        F: FnMut(&Self::Atom) -> <E as Expression>::Atom,
        <E as Expression>::Group: FromIterator<E>
, { ... }
fn substitute<F>(self, f: F) -> Self
    where
        F: FnMut(Self::Atom) -> Self,
        Self::Group: FromIterator<Self>,
        Self::Group: IntoIterator,
        <Self::Group as IntoIterator>::Item == Self
, { ... }
fn substitute_ref<F>(&self, f: F) -> Self
    where
        F: FnMut(&Self::Atom) -> Self,
        Self::Group: FromIterator<Self>
, { ... } }

Expression Tree

Associated Types

type Atom

Atomic Element Type

type Group: IntoIteratorGen<Self>

Group Expression Type

Loading content...

Required methods

fn cases(&self) -> ExprRef<'_, Self>

Get a reference to the underlying Expression type.

fn from_atom(atom: Self::Atom) -> Self

Build an Expression from an atomic element.

fn from_group(group: Self::Group) -> Self

Build an Expression from a grouped expression.

Loading content...

Provided methods

#[must_use]fn from_expr(expr: Expr<Self>) -> Self

Convert from the canonical enumeration.

fn from_str(s: &str) -> Result<Self, Error> where
    Self::Atom: FromIterator<char>,
    Self::Group: FromIterator<Self>, 

Parse a string into an Expression.

#[must_use]fn is_atom(&self) -> bool

Check if the Expression is atomic.

#[must_use]fn is_group(&self) -> bool

Check if the Expression is a grouped expression.

#[must_use]fn atom(self) -> Option<Self::Atom>

Converts from an Expression to an Option<E::Atom>.

#[must_use]fn group(self) -> Option<Self::Group>

Converts from an Expression to an Option<E::Group>.

fn unwrap_atom(self) -> Self::Atom

Returns the contained Atom value, consuming the self value.

Panics

Panics if the self value is a Group.

fn unwrap_group(self) -> Self::Group

Returns the contained Group value, consuming the self value.

Panics

Panics if the self value is an Atom.

fn empty_atom<T>() -> Self where
    Self::Atom: FromIterator<T>, 

Build an empty atomic expression.

fn empty_group() -> Self where
    Self::Group: FromIterator<Self>, 

Build an empty grouped expression.

fn default() -> Self where
    Self::Group: FromIterator<Self>, 

Get the default value of an Expression: the empty group.

fn clone(&self) -> Self where
    Self::Atom: Clone,
    Self::Group: FromIterator<Self>, 

Clone an Expression that has Clone-able Atoms.

fn eq<E>(&self, other: &E) -> bool where
    E: Expression,
    Self::Atom: PartialEq<<E as Expression>::Atom>, 

Check if two Expressions are equal using PartialEq on their Atoms.

fn is_subexpression<E>(&self, other: &E) -> bool where
    E: Expression,
    Self::Atom: PartialEq<<E as Expression>::Atom>, 

Check if an Expression is a sub-tree of another Expression using PartialEq on their Atoms.

fn map<E, F>(self, f: F) -> E where
    E: Expression,
    F: FnMut(Self::Atom) -> <E as Expression>::Atom,
    Self::Group: IntoIterator,
    <E as Expression>::Group: FromIterator<E>,
    <Self::Group as IntoIterator>::Item == Self, 

Extend a function on Atoms to a function on Expressions.

fn map_ref<E, F>(&self, f: F) -> E where
    E: Expression,
    F: FnMut(&Self::Atom) -> <E as Expression>::Atom,
    <E as Expression>::Group: FromIterator<E>, 

Extend a function on &Atoms to a function on &Expressions.

fn substitute<F>(self, f: F) -> Self where
    F: FnMut(Self::Atom) -> Self,
    Self::Group: FromIterator<Self>,
    Self::Group: IntoIterator,
    <Self::Group as IntoIterator>::Item == Self, 

Substitute an Expression into each Atom of self.

fn substitute_ref<F>(&self, f: F) -> Self where
    F: FnMut(&Self::Atom) -> Self,
    Self::Group: FromIterator<Self>, 

Substitute an Expression into each Atom of &self.

Loading content...

Implementors

impl<A> Expression for Expr<A>[src]

type Atom = A

type Group = Vec<Self>

Loading content...