22
33use super :: haystack:: { Hay , Haystack , Span } ;
44use super :: needle:: {
5- Needle , Searcher , ReverseSearcher , DoubleEndedSearcher ,
6- Consumer , ReverseConsumer , DoubleEndedConsumer ,
5+ Consumer , DoubleEndedConsumer , DoubleEndedSearcher , Needle , ReverseConsumer , ReverseSearcher ,
6+ Searcher ,
77} ;
8+ use crate :: fmt;
89use crate :: iter:: FusedIterator ;
910use crate :: ops:: Range ;
10- use crate :: fmt;
1111
1212macro_rules! generate_clone_and_debug {
1313 ( $name: ident, $field: tt) => {
@@ -32,12 +32,10 @@ macro_rules! generate_clone_and_debug {
3232 H :: Target : Hay , // FIXME: RFC 2089 or 2289
3333 {
3434 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( )
3836 }
3937 }
40- }
38+ } ;
4139}
4240
4341macro_rules! generate_pattern_iterators {
@@ -333,10 +331,7 @@ where
333331 P : Needle < H > ,
334332 H :: Target : Hay , // FIXME: RFC 2089 or 2289
335333{
336- Matches ( MatchesInternal {
337- searcher : needle. into_searcher ( ) ,
338- rest : haystack. into ( ) ,
339- } )
334+ Matches ( MatchesInternal { searcher : needle. into_searcher ( ) , rest : haystack. into ( ) } )
340335}
341336
342337/// An iterator over the disjoint matches of the needle within the haystack,
@@ -348,10 +343,7 @@ where
348343 P :: Searcher : ReverseSearcher < H :: Target > ,
349344 H :: Target : Hay , // FIXME: RFC 2089 or 2289
350345{
351- RMatches ( MatchesInternal {
352- searcher : needle. into_searcher ( ) ,
353- rest : haystack. into ( ) ,
354- } )
346+ RMatches ( MatchesInternal { searcher : needle. into_searcher ( ) , rest : haystack. into ( ) } )
355347}
356348
357349/// Returns `true` if the given needle matches a sub-slice of the haystack.
@@ -363,9 +355,7 @@ where
363355 P : Needle < H > ,
364356 H :: Target : Hay , // FIXME: RFC 2089 or 2289
365357{
366- needle. into_searcher ( )
367- . search ( ( * haystack) . into ( ) )
368- . is_some ( )
358+ needle. into_searcher ( ) . search ( ( * haystack) . into ( ) ) . is_some ( )
369359}
370360
371361//------------------------------------------------------------------------------
@@ -434,9 +424,7 @@ where
434424 P : Needle < H > ,
435425 H :: Target : Hay , // FIXME: RFC 2089 or 2289
436426{
437- MatchIndices ( MatchIndicesInternal {
438- inner : matches ( haystack, needle) . 0 ,
439- } )
427+ MatchIndices ( MatchIndicesInternal { inner : matches ( haystack, needle) . 0 } )
440428}
441429
442430/// An iterator over the disjoint matches of a needle within the haystack,
@@ -451,9 +439,7 @@ where
451439 P :: Searcher : ReverseSearcher < H :: Target > ,
452440 H :: Target : Hay , // FIXME: RFC 2089 or 2289
453441{
454- RMatchIndices ( MatchIndicesInternal {
455- inner : rmatches ( haystack, needle) . 0 ,
456- } )
442+ RMatchIndices ( MatchIndicesInternal { inner : rmatches ( haystack, needle) . 0 } )
457443}
458444
459445/// Returns the start index of first slice of the haystack that matches the needle.
@@ -466,9 +452,7 @@ where
466452 P : Needle < H > ,
467453 H :: Target : Hay , // FIXME: RFC 2089 or 2289
468454{
469- needle. into_searcher ( )
470- . search ( ( * haystack) . into ( ) )
471- . map ( |r| r. start )
455+ needle. into_searcher ( ) . search ( ( * haystack) . into ( ) ) . map ( |r| r. start )
472456}
473457
474458/// Returns the start index of last slice of the haystack that matches the needle.
@@ -481,9 +465,7 @@ where
481465 P :: Searcher : ReverseSearcher < H :: Target > ,
482466 H :: Target : Hay , // FIXME: RFC 2089 or 2289
483467{
484- needle. into_searcher ( )
485- . rsearch ( ( * haystack) . into ( ) )
486- . map ( |r| r. start )
468+ needle. into_searcher ( ) . rsearch ( ( * haystack) . into ( ) ) . map ( |r| r. start )
487469}
488470
489471//------------------------------------------------------------------------------
@@ -552,9 +534,7 @@ where
552534 P : Needle < H > ,
553535 H :: Target : Hay , // FIXME: RFC 2089 or 2289
554536{
555- MatchRanges ( MatchRangesInternal {
556- inner : matches ( haystack, needle) . 0 ,
557- } )
537+ MatchRanges ( MatchRangesInternal { inner : matches ( haystack, needle) . 0 } )
558538}
559539
560540/// An iterator over the disjoint matches of a needle within the haystack,
@@ -569,9 +549,7 @@ where
569549 P :: Searcher : ReverseSearcher < H :: Target > ,
570550 H :: Target : Hay , // FIXME: RFC 2089 or 2289
571551{
572- RMatchRanges ( MatchRangesInternal {
573- inner : rmatches ( haystack, needle) . 0 ,
574- } )
552+ RMatchRanges ( MatchRangesInternal { inner : rmatches ( haystack, needle) . 0 } )
575553}
576554
577555/// Returns the index range of first slice of the haystack that matches the needle.
@@ -583,8 +561,7 @@ where
583561 P : Needle < H > ,
584562 H :: Target : Hay , // FIXME: RFC 2089 or 2289
585563{
586- needle. into_searcher ( )
587- . search ( ( * haystack) . into ( ) )
564+ needle. into_searcher ( ) . search ( ( * haystack) . into ( ) )
588565}
589566
590567/// Returns the start index of last slice of the haystack that matches the needle.
@@ -597,8 +574,7 @@ where
597574 P :: Searcher : ReverseSearcher < H :: Target > ,
598575 H :: Target : Hay , // FIXME: RFC 2089 or 2289
599576{
600- needle. into_searcher ( )
601- . rsearch ( ( * haystack) . into ( ) )
577+ needle. into_searcher ( ) . rsearch ( ( * haystack) . into ( ) )
602578}
603579
604580//------------------------------------------------------------------------------
@@ -814,19 +790,17 @@ where
814790 1 => {
815791 self . n = 0 ;
816792 }
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;
828799 }
829- }
800+ None => {
801+ self . n = 0 ;
802+ }
803+ } ,
830804 }
831805 Some ( Span :: into ( rest) )
832806 }
@@ -848,19 +822,17 @@ where
848822 1 => {
849823 self . n = 0 ;
850824 }
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;
862831 }
863- }
832+ None => {
833+ self . n = 0 ;
834+ }
835+ } ,
864836 }
865837 Some ( Span :: into ( rest) )
866838 }
@@ -890,11 +862,7 @@ where
890862 P : Needle < H > ,
891863 H :: Target : Hay , // FIXME: RFC 2089 or 2289
892864{
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 } )
898866}
899867
900868/// An iterator over slices of the given haystack, separated by a needle,
@@ -909,11 +877,7 @@ where
909877 P :: Searcher : ReverseSearcher < H :: Target > ,
910878 H :: Target : Hay , // FIXME: RFC 2089 or 2289
911879{
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 } )
917881}
918882
919883//------------------------------------------------------------------------------
0 commit comments