2
2
3
3
use super :: haystack:: { Hay , Haystack , Span } ;
4
4
use super :: needle:: {
5
- Needle , Searcher , ReverseSearcher , DoubleEndedSearcher ,
6
- Consumer , ReverseConsumer , DoubleEndedConsumer ,
5
+ Consumer , DoubleEndedConsumer , DoubleEndedSearcher , Needle , ReverseConsumer , ReverseSearcher ,
6
+ Searcher ,
7
7
} ;
8
+ use crate :: fmt;
8
9
use crate :: iter:: FusedIterator ;
9
10
use crate :: ops:: Range ;
10
- use crate :: fmt;
11
11
12
12
macro_rules! generate_clone_and_debug {
13
13
( $name: ident, $field: tt) => {
@@ -32,12 +32,10 @@ macro_rules! generate_clone_and_debug {
32
32
H :: Target : Hay , // FIXME: RFC 2089 or 2289
33
33
{
34
34
fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
35
- f. debug_tuple( stringify!( $name) )
36
- . field( & self . $field)
37
- . finish( )
35
+ f. debug_tuple( stringify!( $name) ) . field( & self . $field) . finish( )
38
36
}
39
37
}
40
- }
38
+ } ;
41
39
}
42
40
43
41
macro_rules! generate_pattern_iterators {
@@ -333,10 +331,7 @@ where
333
331
P : Needle < H > ,
334
332
H :: Target : Hay , // FIXME: RFC 2089 or 2289
335
333
{
336
- Matches ( MatchesInternal {
337
- searcher : needle. into_searcher ( ) ,
338
- rest : haystack. into ( ) ,
339
- } )
334
+ Matches ( MatchesInternal { searcher : needle. into_searcher ( ) , rest : haystack. into ( ) } )
340
335
}
341
336
342
337
/// An iterator over the disjoint matches of the needle within the haystack,
@@ -348,10 +343,7 @@ where
348
343
P :: Searcher : ReverseSearcher < H :: Target > ,
349
344
H :: Target : Hay , // FIXME: RFC 2089 or 2289
350
345
{
351
- RMatches ( MatchesInternal {
352
- searcher : needle. into_searcher ( ) ,
353
- rest : haystack. into ( ) ,
354
- } )
346
+ RMatches ( MatchesInternal { searcher : needle. into_searcher ( ) , rest : haystack. into ( ) } )
355
347
}
356
348
357
349
/// Returns `true` if the given needle matches a sub-slice of the haystack.
@@ -363,9 +355,7 @@ where
363
355
P : Needle < H > ,
364
356
H :: Target : Hay , // FIXME: RFC 2089 or 2289
365
357
{
366
- needle. into_searcher ( )
367
- . search ( ( * haystack) . into ( ) )
368
- . is_some ( )
358
+ needle. into_searcher ( ) . search ( ( * haystack) . into ( ) ) . is_some ( )
369
359
}
370
360
371
361
//------------------------------------------------------------------------------
@@ -434,9 +424,7 @@ where
434
424
P : Needle < H > ,
435
425
H :: Target : Hay , // FIXME: RFC 2089 or 2289
436
426
{
437
- MatchIndices ( MatchIndicesInternal {
438
- inner : matches ( haystack, needle) . 0 ,
439
- } )
427
+ MatchIndices ( MatchIndicesInternal { inner : matches ( haystack, needle) . 0 } )
440
428
}
441
429
442
430
/// An iterator over the disjoint matches of a needle within the haystack,
@@ -451,9 +439,7 @@ where
451
439
P :: Searcher : ReverseSearcher < H :: Target > ,
452
440
H :: Target : Hay , // FIXME: RFC 2089 or 2289
453
441
{
454
- RMatchIndices ( MatchIndicesInternal {
455
- inner : rmatches ( haystack, needle) . 0 ,
456
- } )
442
+ RMatchIndices ( MatchIndicesInternal { inner : rmatches ( haystack, needle) . 0 } )
457
443
}
458
444
459
445
/// Returns the start index of first slice of the haystack that matches the needle.
@@ -466,9 +452,7 @@ where
466
452
P : Needle < H > ,
467
453
H :: Target : Hay , // FIXME: RFC 2089 or 2289
468
454
{
469
- needle. into_searcher ( )
470
- . search ( ( * haystack) . into ( ) )
471
- . map ( |r| r. start )
455
+ needle. into_searcher ( ) . search ( ( * haystack) . into ( ) ) . map ( |r| r. start )
472
456
}
473
457
474
458
/// Returns the start index of last slice of the haystack that matches the needle.
@@ -481,9 +465,7 @@ where
481
465
P :: Searcher : ReverseSearcher < H :: Target > ,
482
466
H :: Target : Hay , // FIXME: RFC 2089 or 2289
483
467
{
484
- needle. into_searcher ( )
485
- . rsearch ( ( * haystack) . into ( ) )
486
- . map ( |r| r. start )
468
+ needle. into_searcher ( ) . rsearch ( ( * haystack) . into ( ) ) . map ( |r| r. start )
487
469
}
488
470
489
471
//------------------------------------------------------------------------------
@@ -552,9 +534,7 @@ where
552
534
P : Needle < H > ,
553
535
H :: Target : Hay , // FIXME: RFC 2089 or 2289
554
536
{
555
- MatchRanges ( MatchRangesInternal {
556
- inner : matches ( haystack, needle) . 0 ,
557
- } )
537
+ MatchRanges ( MatchRangesInternal { inner : matches ( haystack, needle) . 0 } )
558
538
}
559
539
560
540
/// An iterator over the disjoint matches of a needle within the haystack,
@@ -569,9 +549,7 @@ where
569
549
P :: Searcher : ReverseSearcher < H :: Target > ,
570
550
H :: Target : Hay , // FIXME: RFC 2089 or 2289
571
551
{
572
- RMatchRanges ( MatchRangesInternal {
573
- inner : rmatches ( haystack, needle) . 0 ,
574
- } )
552
+ RMatchRanges ( MatchRangesInternal { inner : rmatches ( haystack, needle) . 0 } )
575
553
}
576
554
577
555
/// Returns the index range of first slice of the haystack that matches the needle.
@@ -583,8 +561,7 @@ where
583
561
P : Needle < H > ,
584
562
H :: Target : Hay , // FIXME: RFC 2089 or 2289
585
563
{
586
- needle. into_searcher ( )
587
- . search ( ( * haystack) . into ( ) )
564
+ needle. into_searcher ( ) . search ( ( * haystack) . into ( ) )
588
565
}
589
566
590
567
/// Returns the start index of last slice of the haystack that matches the needle.
@@ -597,8 +574,7 @@ where
597
574
P :: Searcher : ReverseSearcher < H :: Target > ,
598
575
H :: Target : Hay , // FIXME: RFC 2089 or 2289
599
576
{
600
- needle. into_searcher ( )
601
- . rsearch ( ( * haystack) . into ( ) )
577
+ needle. into_searcher ( ) . rsearch ( ( * haystack) . into ( ) )
602
578
}
603
579
604
580
//------------------------------------------------------------------------------
@@ -814,19 +790,17 @@ where
814
790
1 => {
815
791
self . n = 0 ;
816
792
}
817
- n => {
818
- match self . searcher . search ( rest. borrow ( ) ) {
819
- Some ( range) => {
820
- let [ left, _, right] = unsafe { rest. split_around ( range) } ;
821
- self . n = n - 1 ;
822
- self . rest = right;
823
- rest = left;
824
- }
825
- None => {
826
- self . n = 0 ;
827
- }
793
+ n => match self . searcher . search ( rest. borrow ( ) ) {
794
+ Some ( range) => {
795
+ let [ left, _, right] = unsafe { rest. split_around ( range) } ;
796
+ self . n = n - 1 ;
797
+ self . rest = right;
798
+ rest = left;
828
799
}
829
- }
800
+ None => {
801
+ self . n = 0 ;
802
+ }
803
+ } ,
830
804
}
831
805
Some ( Span :: into ( rest) )
832
806
}
@@ -848,19 +822,17 @@ where
848
822
1 => {
849
823
self . n = 0 ;
850
824
}
851
- n => {
852
- match self . searcher . rsearch ( rest. borrow ( ) ) {
853
- Some ( range) => {
854
- let [ left, _, right] = unsafe { rest. split_around ( range) } ;
855
- self . n = n - 1 ;
856
- self . rest = left;
857
- rest = right;
858
- }
859
- None => {
860
- self . n = 0 ;
861
- }
825
+ n => match self . searcher . rsearch ( rest. borrow ( ) ) {
826
+ Some ( range) => {
827
+ let [ left, _, right] = unsafe { rest. split_around ( range) } ;
828
+ self . n = n - 1 ;
829
+ self . rest = left;
830
+ rest = right;
862
831
}
863
- }
832
+ None => {
833
+ self . n = 0 ;
834
+ }
835
+ } ,
864
836
}
865
837
Some ( Span :: into ( rest) )
866
838
}
@@ -890,11 +862,7 @@ where
890
862
P : Needle < H > ,
891
863
H :: Target : Hay , // FIXME: RFC 2089 or 2289
892
864
{
893
- SplitN ( SplitNInternal {
894
- searcher : needle. into_searcher ( ) ,
895
- rest : haystack. into ( ) ,
896
- n,
897
- } )
865
+ SplitN ( SplitNInternal { searcher : needle. into_searcher ( ) , rest : haystack. into ( ) , n } )
898
866
}
899
867
900
868
/// An iterator over slices of the given haystack, separated by a needle,
@@ -909,11 +877,7 @@ where
909
877
P :: Searcher : ReverseSearcher < H :: Target > ,
910
878
H :: Target : Hay , // FIXME: RFC 2089 or 2289
911
879
{
912
- RSplitN ( SplitNInternal {
913
- searcher : needle. into_searcher ( ) ,
914
- rest : haystack. into ( ) ,
915
- n,
916
- } )
880
+ RSplitN ( SplitNInternal { searcher : needle. into_searcher ( ) , rest : haystack. into ( ) , n } )
917
881
}
918
882
919
883
//------------------------------------------------------------------------------
0 commit comments