11use super :: {
2+ ValueExpr ,
23 field_expr:: IdentifierExpr ,
34 parse:: FilterParser ,
45 visitor:: { Visitor , VisitorMut } ,
5- ValueExpr ,
66} ;
77use crate :: {
88 compiler:: Compiler ,
99 execution_context:: ExecutionContext ,
1010 filter:: {
1111 CompiledExpr , CompiledOneExpr , CompiledValueExpr , CompiledVecExpr , CompiledVecExprResult ,
1212 } ,
13- lex:: { expect , skip_space , span , Lex , LexErrorKind , LexResult , LexWith } ,
13+ lex:: { Lex , LexErrorKind , LexResult , LexWith , expect , skip_space , span } ,
1414 lhs_types:: { Array , Map , TypedArray } ,
1515 scheme:: { FieldIndex , IndexAccessError } ,
1616 types:: { GetType , IntoIter , LhsValue , Type } ,
1717} ;
18- use serde:: { ser :: SerializeSeq , Serialize , Serializer } ;
18+ use serde:: { Serialize , Serializer , ser :: SerializeSeq } ;
1919
2020/// IndexExpr is an expr that destructures an index into an IdentifierExpr.
2121///
@@ -282,10 +282,13 @@ impl IndexExpr {
282282 let call = compiler. compile_function_call_expr ( call) ;
283283 CompiledVecExpr :: new ( move |ctx| {
284284 let mut iter = MapEachIterator :: from_indexes ( & indexes[ ..] ) ;
285- if let Ok ( val) = call. execute ( ctx) {
286- iter. reset ( val) ;
287- } else {
288- return TypedArray :: default ( ) ;
285+ match call. execute ( ctx) {
286+ Ok ( val) => {
287+ iter. reset ( val) ;
288+ }
289+ _ => {
290+ return TypedArray :: default ( ) ;
291+ }
289292 }
290293
291294 TypedArray :: from_iter ( iter. map ( |item| func ( & item, ctx) ) )
@@ -363,7 +366,7 @@ impl<'i, 's> LexWith<'i, &FilterParser<'s>> for IndexExpr {
363366 actual : current_type,
364367 } ) ,
365368 span ( input, rest) ,
366- ) )
369+ ) ) ;
367370 }
368371 } ,
369372 FieldIndex :: MapKey ( _) => match current_type {
@@ -377,7 +380,7 @@ impl<'i, 's> LexWith<'i, &FilterParser<'s>> for IndexExpr {
377380 actual : current_type,
378381 } ) ,
379382 span ( input, rest) ,
380- ) )
383+ ) ) ;
381384 }
382385 } ,
383386 FieldIndex :: MapEach => match current_type {
@@ -394,7 +397,7 @@ impl<'i, 's> LexWith<'i, &FilterParser<'s>> for IndexExpr {
394397 actual : current_type,
395398 } ) ,
396399 span ( input, rest) ,
397- ) )
400+ ) ) ;
398401 }
399402 } ,
400403 } ;
@@ -544,9 +547,9 @@ impl<'a> Iterator for MapEachIterator<'a, '_> {
544547mod tests {
545548 use super :: * ;
546549 use crate :: {
547- ast :: field_expr :: IdentifierExpr , Array , FieldIndex , FilterParser , FunctionArgKind ,
548- FunctionArgs , FunctionCallArgExpr , FunctionCallExpr , Scheme , SchemeBuilder ,
549- SimpleFunctionDefinition , SimpleFunctionImpl , SimpleFunctionParam ,
550+ Array , FieldIndex , FilterParser , FunctionArgKind , FunctionArgs , FunctionCallArgExpr ,
551+ FunctionCallExpr , Scheme , SchemeBuilder , SimpleFunctionDefinition , SimpleFunctionImpl ,
552+ SimpleFunctionParam , ast :: field_expr :: IdentifierExpr ,
550553 } ;
551554 use std:: sync:: LazyLock ;
552555
0 commit comments