feat(value): less clone

This commit is contained in:
2025-05-17 15:18:16 +08:00
parent 85f06a30cd
commit 8480e0891b
10 changed files with 154 additions and 127 deletions

View File

@@ -50,7 +50,7 @@ pub struct Func<'vm> {
}
impl<'vm> Func<'vm> {
pub fn call(self, vm: &'vm VM<'_>, arg: Value<'vm>) -> Result<Value<'vm>> {
pub fn call(&self, vm: &'vm VM<'_>, arg: Value<'vm>) -> Result<Value<'vm>> {
use Param::*;
let env = Rc::new(self.env.as_ref().clone());
@@ -78,7 +78,7 @@ impl<'vm> Func<'vm> {
let formal = formal.clone().into();
let arg = arg
.select(formal)
.or_else(|| default.map(|idx| Value::Thunk(Thunk::new(vm.get_thunk(idx)))))
.or_else(|| default.map(|idx| Value::Thunk(Thunk::new(vm.get_thunk(idx)).into())))
.unwrap();
new.insert_mut(formal, arg);
}