feat: use Rc for more things, fib_iter runs almost 3 seconds faster now
This commit is contained in:
@@ -3,27 +3,27 @@ use crate::program_builder::WithTerm;
|
||||
|
||||
pub trait WithConstant: WithTerm {
|
||||
fn with_int(self, int: i128) -> Self::Next {
|
||||
let term = Term::Constant(Constant::Integer(int));
|
||||
let term = Term::Constant(Constant::Integer(int).into());
|
||||
self.next(term)
|
||||
}
|
||||
|
||||
fn with_byte_string(self, bytes: Vec<u8>) -> Self::Next {
|
||||
let term = Term::Constant(Constant::ByteString(bytes));
|
||||
let term = Term::Constant(Constant::ByteString(bytes).into());
|
||||
self.next(term)
|
||||
}
|
||||
|
||||
fn with_string(self, string: String) -> Self::Next {
|
||||
let term = Term::Constant(Constant::String(string));
|
||||
let term = Term::Constant(Constant::String(string).into());
|
||||
self.next(term)
|
||||
}
|
||||
|
||||
fn with_unit(self) -> Self::Next {
|
||||
let term = Term::Constant(Constant::Unit);
|
||||
let term = Term::Constant(Constant::Unit.into());
|
||||
self.next(term)
|
||||
}
|
||||
|
||||
fn with_bool(self, bool: bool) -> Self::Next {
|
||||
let term = Term::Constant(Constant::Bool(bool));
|
||||
let term = Term::Constant(Constant::Bool(bool).into());
|
||||
self.next(term)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ impl<T: WithTerm> WithTerm for LambdaBuilder<T> {
|
||||
|
||||
fn next(self, term: Term<Name>) -> Self::Next {
|
||||
let term = Term::Lambda {
|
||||
parameter_name: self.parameter_name,
|
||||
parameter_name: self.parameter_name.into(),
|
||||
body: Rc::new(term),
|
||||
};
|
||||
self.outer.next(term)
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::program_builder::WithTerm;
|
||||
pub trait WithVar: WithTerm {
|
||||
fn with_var(self, name_str: &str) -> Self::Next {
|
||||
let name = self.get_name(name_str);
|
||||
let term = Term::Var(name);
|
||||
let term = Term::Var(name.into());
|
||||
self.next(term)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user