Struct egg::RecExpr

source · []
pub struct RecExpr<L> { /* private fields */ }
Expand description

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. For example, the expression (+ (* x 5) x) could be represented by a recursive expression of the form [Num(5), Var("x"), Mul(1, 0), Add(2, 1)].

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

Implementations

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

Checks if this expr is a DAG, i.e. doesn’t have any back edges

Pretty print with a maximum line length.

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

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

Returns a new PatternAst with the variables renames canonically

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.