[][src]Struct egg::RecExpr

pub struct RecExpr<L> { /* fields omitted */ }

A recursive expression from a user-defined Language.

This is type is essentially an ENode whose children are RecExprs. This is resource counted with Rc, so it's cheap to clone.

If the serde-1 feature is enabled, this implements serde::Serialize by pretty-printing with self.pretty(80).

Methods

impl<L: Language + Display> RecExpr<L>[src]

pub fn pretty(&self, width: usize) -> String[src]

Pretty print with a maximum line length.

This gives you a nice, indented, pretty-printed s-expression.

Example

define_language! {
    enum FooLanguage {
        Num(i32),
        Add = "+",
        Mul = "*",
        Symbol(String),
    }
}

let e: RecExpr<FooLanguage> = "(* (+ 2 2) (+ x y))".parse().unwrap();
assert_eq!(e.pretty(10), "
(*
  (+ 2 2)
  (+ x y))
".trim());

Trait Implementations

impl<L> AsRef<ENode<L, RecExpr<L>>> for RecExpr<L>[src]

impl<L> Borrow<ENode<L, RecExpr<L>>> for RecExpr<L>[src]

impl<L: Clone> Clone for RecExpr<L>[src]

impl<L: Debug> Debug for RecExpr<L>[src]

impl<L: Eq> Eq for RecExpr<L>[src]

impl<L> From<ENode<L, RecExpr<L>>> for RecExpr<L>[src]

impl<L: Language> From<RecExpr<L>> for Pattern<L>[src]

impl<L: Language + FromStr> FromStr for RecExpr<L>[src]

type Err = ParseError

The associated error which can be returned from parsing.

impl<L: Hash> Hash for RecExpr<L>[src]

impl<L: PartialEq> PartialEq<RecExpr<L>> for RecExpr<L>[src]

impl<L> StructuralEq for RecExpr<L>[src]

impl<L> StructuralPartialEq for RecExpr<L>[src]

impl<L: Language> TryFrom<Pattern<L>> for RecExpr<L>[src]

type Error = String

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<L> !RefUnwindSafe for RecExpr<L>

impl<L> !Send for RecExpr<L>

impl<L> !Sync for RecExpr<L>

impl<L> Unpin for RecExpr<L>

impl<L> !UnwindSafe for RecExpr<L>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.