summaryrefslogtreecommitdiff
path: root/src/model/dict.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-30 19:40:29 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-30 20:00:50 +0100
commita6d90c1bf1e9fefa0af04206909a40e112d6bb14 (patch)
treefc16276142f74b9a50102a2e855942f7e2593c25 /src/model/dict.rs
parentf70cea508cd30fa40770ea989fe2a19e715a357b (diff)
Numbering functions
Diffstat (limited to 'src/model/dict.rs')
-rw-r--r--src/model/dict.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/model/dict.rs b/src/model/dict.rs
index 83c16824..a5dbeeae 100644
--- a/src/model/dict.rs
+++ b/src/model/dict.rs
@@ -6,7 +6,6 @@ use std::sync::Arc;
use super::{Args, Array, Func, Str, Value, Vm};
use crate::diag::{bail, SourceResult, StrResult};
use crate::syntax::is_ident;
-use crate::syntax::Spanned;
use crate::util::{format_eco, ArcExt, EcoString};
/// Create a new [`Dict`] from key-value pairs.
@@ -107,14 +106,15 @@ impl Dict {
}
/// Transform each pair in the dictionary with a function.
- pub fn map(&self, vm: &Vm, f: Spanned<Func>) -> SourceResult<Array> {
- if f.v.argc().map_or(false, |count| count != 1) {
- bail!(f.span, "function must have exactly two parameters");
+ pub fn map(&self, vm: &Vm, func: Func) -> SourceResult<Array> {
+ if func.argc().map_or(false, |count| count != 2) {
+ bail!(func.span(), "function must have exactly two parameters");
}
self.iter()
.map(|(key, value)| {
- let args = Args::new(f.span, [Value::Str(key.clone()), value.clone()]);
- f.v.call(vm, args)
+ let args =
+ Args::new(func.span(), [Value::Str(key.clone()), value.clone()]);
+ func.call(vm, args)
})
.collect()
}