Implement List.any

This commit is contained in:
Kevin Sjöberg 2021-11-05 23:34:10 +01:00
parent 0e500ba33c
commit 44938a9e35
15 changed files with 137 additions and 6 deletions

View file

@ -617,7 +617,8 @@ impl<'a> BorrowInfState<'a> {
ListMap { xs }
| ListKeepIf { xs }
| ListKeepOks { xs }
| ListKeepErrs { xs } => {
| ListKeepErrs { xs }
| ListAny { xs } => {
// own the list if the function wants to own the element
if !function_ps[0].borrow {
self.own_var(*xs);
@ -949,7 +950,7 @@ pub fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[bool] {
ListMap2 => arena.alloc_slice_copy(&[owned, owned, function, closure_data]),
ListMap3 => arena.alloc_slice_copy(&[owned, owned, owned, function, closure_data]),
ListMap4 => arena.alloc_slice_copy(&[owned, owned, owned, owned, function, closure_data]),
ListKeepIf | ListKeepOks | ListKeepErrs => {
ListKeepIf | ListKeepOks | ListKeepErrs | ListAny => {
arena.alloc_slice_copy(&[owned, function, closure_data])
}
ListContains => arena.alloc_slice_copy(&[borrowed, irrelevant]),