feat: start when expressions

This commit is contained in:
rvcas
2022-11-27 16:54:59 -05:00
committed by Lucas
parent 8b24a66b7e
commit 86ea41adc3
5 changed files with 157 additions and 13 deletions

View File

@@ -110,6 +110,16 @@ pub enum Term<T> {
Builtin(DefaultFunction),
}
impl<T> Term<T> {
pub fn is_unit(&self) -> bool {
matches!(self, Term::Constant(Constant::Unit))
}
pub fn force_wrap(self) -> Self {
Term::Force(self.into())
}
}
impl<'a, T> Display for Term<T>
where
T: Binder<'a>,

View File

@@ -1,9 +1,11 @@
use std::{fmt::Display, str::FromStr};
use std::{fmt::Display, rc::Rc, str::FromStr};
use strum_macros::EnumIter;
use flat_rs::de;
use crate::ast::Term;
/// All the possible builtin functions in Untyped Plutus Core.
#[repr(u8)]
#[allow(non_camel_case_types)]
@@ -389,3 +391,15 @@ impl DefaultFunction {
.to_string()
}
}
impl<T> From<DefaultFunction> for Term<T> {
fn from(builtin: DefaultFunction) -> Self {
Term::Builtin(builtin)
}
}
impl<T> From<DefaultFunction> for Rc<Term<T>> {
fn from(builtin: DefaultFunction) -> Self {
Term::Builtin(builtin).into()
}
}