summaryrefslogtreecommitdiff
path: root/src/model/func.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-04 09:30:44 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-04 11:38:09 +0100
commiteb951c008beea502042db4a3a0e8d1f8b51f6f52 (patch)
tree9856ee4ed0222222669de10e616a580b2a60135e /src/model/func.rs
parent33928a00dc58250e24da1dae4e5db17e7b598d70 (diff)
Style changes
Diffstat (limited to 'src/model/func.rs')
-rw-r--r--src/model/func.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/model/func.rs b/src/model/func.rs
index 5be1aae3..456b6aa6 100644
--- a/src/model/func.rs
+++ b/src/model/func.rs
@@ -32,12 +32,7 @@ impl Func {
name: &'static str,
func: fn(&mut Vm, &mut Args) -> SourceResult<Value>,
) -> Self {
- Self(Arc::new(Repr::Native(Native {
- name,
- func,
- set: None,
- node: None,
- })))
+ Self(Arc::new(Repr::Native(Native { name, func, set: None, node: None })))
}
/// Create a new function from a native rust node.
@@ -92,7 +87,7 @@ impl Func {
Repr::Native(native) => (native.func)(vm, &mut args)?,
Repr::Closure(closure) => closure.call(vm, &mut args)?,
Repr::With(wrapped, applied) => {
- args.items.splice(.. 0, applied.items.iter().cloned());
+ args.items.splice(..0, applied.items.iter().cloned());
return wrapped.call(vm, args);
}
};
@@ -194,12 +189,15 @@ impl Closure {
// Parse the arguments according to the parameter list.
for (param, default) in &self.params {
- scopes.top.define(param.clone(), match default {
- None => args.expect::<Value>(param)?,
- Some(default) => {
- args.named::<Value>(param)?.unwrap_or_else(|| default.clone())
- }
- });
+ scopes.top.define(
+ param.clone(),
+ match default {
+ Some(default) => {
+ args.named::<Value>(param)?.unwrap_or_else(|| default.clone())
+ }
+ None => args.expect::<Value>(param)?,
+ },
+ );
}
// Put the remaining arguments into the sink.