Enum knube::exp::Exp [−][src]
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)
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")
becomesa
andCst("x")
becomesx
. - Applications are replaced by a function call. For example
App(Cst("f"), Var("x"))
becomesf(x)
.
impl Eq for Exp
[src]
impl PartialEq<Exp> for Exp
[src]
The comparison is done as follows:
Cst(a) == Cst(b)
iffa == b
, wherea
andb
are strings.Var(a) == Var(b)
iffa == b
, wherea
andb
are strings.App(a, b) == App(c, d)
iff(a == c) && (b == d)
, wherea
,b
,c
, andd
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,