@@ -369,20 +369,18 @@ fn once<F: FnOnce(&mut StackDrive)>(f: F) -> Box<OpOnce<F>> {
369
369
Box :: new ( OpOnce { f : Some ( f) } )
370
370
}
371
371
372
- // F1 F2 are same identical, but workaround for closure
373
372
struct OpTwice < F1 , F2 > {
374
373
f1 : Option < F1 > ,
375
374
f2 : Option < F2 > ,
376
375
}
377
376
impl < F1 , F2 > OpcodeExecutor for OpTwice < F1 , F2 >
378
377
where
379
- F1 : FnOnce ( & mut StackDrive ) ,
378
+ F1 : FnOnce ( & mut StackDrive ) -> Option < ( ) > ,
380
379
F2 : FnOnce ( & mut StackDrive ) ,
381
380
{
382
381
fn next ( & mut self , drive : & mut StackDrive ) -> Option < ( ) > {
383
382
if let Some ( f1) = self . f1 . take ( ) {
384
- f1 ( drive) ;
385
- Some ( ( ) )
383
+ f1 ( drive)
386
384
} else if let Some ( f2) = self . f2 . take ( ) {
387
385
f2 ( drive) ;
388
386
None
@@ -393,7 +391,7 @@ where
393
391
}
394
392
fn twice < F1 , F2 > ( f1 : F1 , f2 : F2 ) -> Box < OpTwice < F1 , F2 > >
395
393
where
396
- F1 : FnOnce ( & mut StackDrive ) ,
394
+ F1 : FnOnce ( & mut StackDrive ) -> Option < ( ) > ,
397
395
F2 : FnOnce ( & mut StackDrive ) ,
398
396
{
399
397
Box :: new ( OpTwice {
@@ -483,11 +481,12 @@ impl OpcodeDispatcher {
483
481
let passed = drive. ctx ( ) . string_position - drive. state . start ;
484
482
if passed < back {
485
483
drive. ctx_mut ( ) . has_matched = Some ( false ) ;
486
- return ;
484
+ return None ;
487
485
}
488
486
drive. state . string_position = drive. ctx ( ) . string_position - back;
489
487
drive. push_new_context ( 3 ) ;
490
488
drive. state . context_stack . last_mut ( ) . unwrap ( ) . toplevel = false ;
489
+ Some ( ( ) )
491
490
} ,
492
491
|drive| {
493
492
let child_ctx = drive. state . popped_context . unwrap ( ) ;
@@ -504,11 +503,12 @@ impl OpcodeDispatcher {
504
503
let passed = drive. ctx ( ) . string_position - drive. state . start ;
505
504
if passed < back {
506
505
drive. skip_code ( drive. peek_code ( 1 ) as usize + 1 ) ;
507
- return ;
506
+ return None ;
508
507
}
509
508
drive. state . string_position = drive. ctx ( ) . string_position - back;
510
509
drive. push_new_context ( 3 ) ;
511
510
drive. state . context_stack . last_mut ( ) . unwrap ( ) . toplevel = false ;
511
+ Some ( ( ) )
512
512
} ,
513
513
|drive| {
514
514
let child_ctx = drive. state . popped_context . unwrap ( ) ;
@@ -598,6 +598,7 @@ impl OpcodeDispatcher {
598
598
drive. state . string_position = drive. ctx ( ) . string_position ;
599
599
// execute UNTIL operator
600
600
drive. push_new_context ( drive. peek_code ( 1 ) as usize + 1 ) ;
601
+ Some ( ( ) )
601
602
} ,
602
603
|drive| {
603
604
drive. state . repeat_stack . pop ( ) ;
0 commit comments