[][src]Struct egg::RecExpr

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

A recursive expression from a user-defined Language.

This conceptually represents a recursive expression, but it's actually just a list of enodes.

RecExprs must satisfy the invariant that enodes' children must refer to elements that come before it in the list.

If the serde-1 feature is enabled, this implements serde::Serialize.

Implementations

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

pub fn add(&mut self, node: L) -> Id[src]

Adds a given enode to this RecExpr. The enode's children Ids must refer to elements already in this list.

impl<L: Language> 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

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

Trait Implementations

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

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

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

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

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

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

type Err = String

The associated error which can be returned from parsing.

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

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

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

type Error = Var

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<L> RefUnwindSafe for RecExpr<L> where
    L: RefUnwindSafe

impl<L> Send for RecExpr<L> where
    L: Send

impl<L> Sync for RecExpr<L> where
    L: Sync

impl<L> Unpin for RecExpr<L> where
    L: Unpin

impl<L> UnwindSafe for RecExpr<L> where
    L: UnwindSafe

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<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> ToString for T where
    T: Display + ?Sized
[src]

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.