diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-09-20 13:05:55 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-09-20 16:37:15 +0200 |
| commit | 757a701c1aa2a6fb80033c7e75666661818da6f9 (patch) | |
| tree | 0415fec94d3856f4ebc97a1744cf2ba75fe8e7aa /src/eval/array.rs | |
| parent | e29f55bb294cc298daad97accf6d8a76976b409c (diff) | |
A New World
Diffstat (limited to 'src/eval/array.rs')
| -rw-r--r-- | src/eval/array.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/eval/array.rs b/src/eval/array.rs index 43261a22..6d558393 100644 --- a/src/eval/array.rs +++ b/src/eval/array.rs @@ -3,7 +3,7 @@ use std::fmt::{self, Debug, Formatter, Write}; use std::ops::{Add, AddAssign}; use std::sync::Arc; -use super::{ops, Args, Func, Machine, Value}; +use super::{ops, Args, Func, Value, Vm}; use crate::diag::{At, StrResult, TypResult}; use crate::syntax::Spanned; use crate::util::ArcExt; @@ -124,7 +124,7 @@ impl Array { } /// Return the first matching element. - pub fn find(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<Option<Value>> { + pub fn find(&self, vm: &mut Vm, f: Spanned<Func>) -> TypResult<Option<Value>> { for item in self.iter() { let args = Args::new(f.span, [item.clone()]); if f.v.call(vm, args)?.cast::<bool>().at(f.span)? { @@ -136,7 +136,7 @@ impl Array { } /// Return the index of the first matching element. - pub fn position(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<Option<i64>> { + pub fn position(&self, vm: &mut Vm, f: Spanned<Func>) -> TypResult<Option<i64>> { for (i, item) in self.iter().enumerate() { let args = Args::new(f.span, [item.clone()]); if f.v.call(vm, args)?.cast::<bool>().at(f.span)? { @@ -149,7 +149,7 @@ impl Array { /// Return a new array with only those elements for which the function /// returns true. - pub fn filter(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<Self> { + pub fn filter(&self, vm: &mut Vm, f: Spanned<Func>) -> TypResult<Self> { let mut kept = vec![]; for item in self.iter() { let args = Args::new(f.span, [item.clone()]); @@ -161,7 +161,7 @@ impl Array { } /// Transform each item in the array with a function. - pub fn map(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<Self> { + pub fn map(&self, vm: &mut Vm, f: Spanned<Func>) -> TypResult<Self> { let enumerate = f.v.argc() == Some(2); Ok(self .iter() @@ -178,7 +178,7 @@ impl Array { } /// Whether any element matches. - pub fn any(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<bool> { + pub fn any(&self, vm: &mut Vm, f: Spanned<Func>) -> TypResult<bool> { for item in self.iter() { let args = Args::new(f.span, [item.clone()]); if f.v.call(vm, args)?.cast::<bool>().at(f.span)? { @@ -190,7 +190,7 @@ impl Array { } /// Whether all elements match. - pub fn all(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<bool> { + pub fn all(&self, vm: &mut Vm, f: Spanned<Func>) -> TypResult<bool> { for item in self.iter() { let args = Args::new(f.span, [item.clone()]); if !f.v.call(vm, args)?.cast::<bool>().at(f.span)? { |
