Enum knube::exp::Exp[][src]

pub enum Exp {
    Cst(&'static str),
    Var(&'static str),
    App(ExpBoxExpBox),
}

A simple expression, as described in the module documentation.

This recursive form is what we study in class. Other implementations might be completely different.

Variants

Cst(&'static str)
Var(&'static str)
App(ExpBoxExpBox)

Implementations

impl Exp[src]

pub fn size(&self) -> usize[src]

Computes the size of the given expression.

The size of an expression is equal to the number of constants it contains added to the number of variables it contains.

Trait Implementations

impl Clone for Exp[src]

impl Debug for Exp[src]

impl Display for Exp[src]

Formats the expressions using the Rust style of expressions.

The expressions are formatted as follows:

  • Variables and constants are replaced by their name. For example Cst("a") becomes a and Cst("x") becomes x.
  • Applications are replaced by a function call. For example App(Cst("f"), Var("x")) becomes f(x).

impl Eq for Exp[src]

impl PartialEq<Exp> for Exp[src]

The comparison is done as follows:

  • Cst(a) == Cst(b) iff a == b, where a and b are strings.
  • Var(a) == Var(b) iff a == b, where a and b are strings.
  • App(a, b) == App(c, d) iff (a == c) && (b == d), where a, b, c, and d are expressions.

This definition of the equality operator matches the behavior of OCaml’s sum type comparison.

impl StructuralEq for Exp[src]

Auto Trait Implementations

impl RefUnwindSafe for Exp

impl Send for Exp

impl Sync for Exp

impl Unpin for Exp

impl UnwindSafe for Exp

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.