Refactor function signatures to use slices

This commit is contained in:
Michael Schimmel
2026-03-03 18:13:20 +01:00
parent 7c38dee243
commit 8c4db9a5ba
12 changed files with 262 additions and 209 deletions
+5 -2
View File
@@ -204,9 +204,12 @@ pub enum Purity {
Pure,
}
pub type NativeFn = dyn Fn(&[Value]) -> Value;
pub type PipeFn = dyn FnMut(&[Value]) -> Value;
/// A native host function with metadata.
pub struct NativeFunction {
pub func: Rc<dyn Fn(Vec<Value>) -> Value>,
pub func: Rc<NativeFn>,
pub purity: Purity,
}
@@ -503,7 +506,7 @@ impl Value {
Value::Record(layout, Rc::new(values))
}
pub fn make_function(purity: Purity, func: impl Fn(Vec<Value>) -> Value + 'static) -> Self {
pub fn make_function(purity: Purity, func: impl Fn(&[Value]) -> Value + 'static) -> Self {
Value::Function(Rc::new(NativeFunction {
func: Rc::new(func),
purity,