@@ -488,7 +488,8 @@ impl<'txt> RustSearcher<'txt> {
488
488
489
489
/// Consumes the next token if it matches the requested value and captures the value if
490
490
/// requested. Returns true if a token was matched.
491
- fn read_token ( & mut self , token : Token < ' _ > , captures : & mut slice:: IterMut < ' _ , & mut & ' txt str > ) -> bool {
491
+ fn read_token ( & mut self , token : Token < ' _ > , captures : & mut [ & mut & ' txt str ] ) -> bool {
492
+ let mut captures = captures. iter_mut ( ) ;
492
493
loop {
493
494
match ( token, self . next_token . kind ) {
494
495
( _, lexer:: TokenKind :: Whitespace )
@@ -552,8 +553,7 @@ impl<'txt> RustSearcher<'txt> {
552
553
553
554
#[ must_use]
554
555
pub fn find_token ( & mut self , token : Token < ' _ > ) -> bool {
555
- let mut capture = [ ] . iter_mut ( ) ;
556
- while !self . read_token ( token, & mut capture) {
556
+ while !self . read_token ( token, & mut [ ] ) {
557
557
self . step ( ) ;
558
558
if self . at_end ( ) {
559
559
return false ;
@@ -566,8 +566,8 @@ impl<'txt> RustSearcher<'txt> {
566
566
pub fn find_capture_token ( & mut self , token : Token < ' _ > ) -> Option < & ' txt str > {
567
567
let mut res = "" ;
568
568
let mut capture = & mut res;
569
- let mut capture = slice:: from_mut ( & mut capture) . iter_mut ( ) ;
570
- while !self . read_token ( token, & mut capture) {
569
+ let capture = slice:: from_mut ( & mut capture) ;
570
+ while !self . read_token ( token, capture) {
571
571
self . step ( ) ;
572
572
if self . at_end ( ) {
573
573
return None ;
@@ -578,8 +578,7 @@ impl<'txt> RustSearcher<'txt> {
578
578
579
579
#[ must_use]
580
580
pub fn match_tokens ( & mut self , tokens : & [ Token < ' _ > ] , captures : & mut [ & mut & ' txt str ] ) -> bool {
581
- let mut captures = captures. iter_mut ( ) ;
582
- tokens. iter ( ) . all ( |& t| self . read_token ( t, & mut captures) )
581
+ tokens. iter ( ) . all ( |& t| self . read_token ( t, captures) )
583
582
}
584
583
}
585
584
0 commit comments