summaryrefslogtreecommitdiff
path: root/src/model/array.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-24 17:39:08 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-24 17:41:41 +0100
commit8d3c68a1deb28dce2b80ed61f85141180ce6a951 (patch)
treede007203d448d6b6a2df7838e802f85d23ccd1a6 /src/model/array.rs
parent5ae81971f299688b05d77af208d7bb44ffce5e2d (diff)
Protect Vm
Diffstat (limited to 'src/model/array.rs')
-rw-r--r--src/model/array.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/model/array.rs b/src/model/array.rs
index 40b063e2..5a2f8672 100644
--- a/src/model/array.rs
+++ b/src/model/array.rs
@@ -128,7 +128,7 @@ impl Array {
}
/// Return the first matching element.
- pub fn find(&self, vm: &mut Vm, f: Spanned<Func>) -> SourceResult<Option<Value>> {
+ pub fn find(&self, vm: &Vm, f: Spanned<Func>) -> SourceResult<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)? {
@@ -140,7 +140,7 @@ impl Array {
}
/// Return the index of the first matching element.
- pub fn position(&self, vm: &mut Vm, f: Spanned<Func>) -> SourceResult<Option<i64>> {
+ pub fn position(&self, vm: &Vm, f: Spanned<Func>) -> SourceResult<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)? {
@@ -153,7 +153,7 @@ impl Array {
/// Return a new array with only those elements for which the function
/// returns true.
- pub fn filter(&self, vm: &mut Vm, f: Spanned<Func>) -> SourceResult<Self> {
+ pub fn filter(&self, vm: &Vm, f: Spanned<Func>) -> SourceResult<Self> {
let mut kept = vec![];
for item in self.iter() {
let args = Args::new(f.span, [item.clone()]);
@@ -165,7 +165,7 @@ impl Array {
}
/// Transform each item in the array with a function.
- pub fn map(&self, vm: &mut Vm, f: Spanned<Func>) -> SourceResult<Self> {
+ pub fn map(&self, vm: &Vm, f: Spanned<Func>) -> SourceResult<Self> {
let enumerate = f.v.argc() == Some(2);
self.iter()
.enumerate()
@@ -181,7 +181,7 @@ impl Array {
}
/// Whether any element matches.
- pub fn any(&self, vm: &mut Vm, f: Spanned<Func>) -> SourceResult<bool> {
+ pub fn any(&self, vm: &Vm, f: Spanned<Func>) -> SourceResult<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)? {
@@ -193,7 +193,7 @@ impl Array {
}
/// Whether all elements match.
- pub fn all(&self, vm: &mut Vm, f: Spanned<Func>) -> SourceResult<bool> {
+ pub fn all(&self, vm: &Vm, f: Spanned<Func>) -> SourceResult<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)? {