@@ -142,13 +142,13 @@ impl One {
142
142
/// * Both `start` and `end` must be valid for reads.
143
143
/// * Both `start` and `end` must point to an initialized value.
144
144
/// * Both `start` and `end` must point to the same allocated object and
145
- /// must either be in bounds or at most one byte past the end of the
146
- /// allocated object.
145
+ /// must either be in bounds or at most one byte past the end of the
146
+ /// allocated object.
147
147
/// * Both `start` and `end` must be _derived from_ a pointer to the same
148
- /// object.
148
+ /// object.
149
149
/// * The distance between `start` and `end` must not overflow `isize`.
150
150
/// * The distance being in bounds must not rely on "wrapping around" the
151
- /// address space.
151
+ /// address space.
152
152
///
153
153
/// Note that callers may pass a pair of pointers such that `start >= end`.
154
154
/// In that case, `None` will always be returned.
@@ -186,13 +186,13 @@ impl One {
186
186
/// * Both `start` and `end` must be valid for reads.
187
187
/// * Both `start` and `end` must point to an initialized value.
188
188
/// * Both `start` and `end` must point to the same allocated object and
189
- /// must either be in bounds or at most one byte past the end of the
190
- /// allocated object.
189
+ /// must either be in bounds or at most one byte past the end of the
190
+ /// allocated object.
191
191
/// * Both `start` and `end` must be _derived from_ a pointer to the same
192
- /// object.
192
+ /// object.
193
193
/// * The distance between `start` and `end` must not overflow `isize`.
194
194
/// * The distance being in bounds must not rely on "wrapping around" the
195
- /// address space.
195
+ /// address space.
196
196
///
197
197
/// Note that callers may pass a pair of pointers such that `start >= end`.
198
198
/// In that case, `None` will always be returned.
@@ -227,13 +227,13 @@ impl One {
227
227
/// * Both `start` and `end` must be valid for reads.
228
228
/// * Both `start` and `end` must point to an initialized value.
229
229
/// * Both `start` and `end` must point to the same allocated object and
230
- /// must either be in bounds or at most one byte past the end of the
231
- /// allocated object.
230
+ /// must either be in bounds or at most one byte past the end of the
231
+ /// allocated object.
232
232
/// * Both `start` and `end` must be _derived from_ a pointer to the same
233
- /// object.
233
+ /// object.
234
234
/// * The distance between `start` and `end` must not overflow `isize`.
235
235
/// * The distance being in bounds must not rely on "wrapping around" the
236
- /// address space.
236
+ /// address space.
237
237
///
238
238
/// Note that callers may pass a pair of pointers such that `start >= end`.
239
239
/// In that case, `None` will always be returned.
@@ -490,13 +490,13 @@ impl Two {
490
490
/// * Both `start` and `end` must be valid for reads.
491
491
/// * Both `start` and `end` must point to an initialized value.
492
492
/// * Both `start` and `end` must point to the same allocated object and
493
- /// must either be in bounds or at most one byte past the end of the
494
- /// allocated object.
493
+ /// must either be in bounds or at most one byte past the end of the
494
+ /// allocated object.
495
495
/// * Both `start` and `end` must be _derived from_ a pointer to the same
496
- /// object.
496
+ /// object.
497
497
/// * The distance between `start` and `end` must not overflow `isize`.
498
498
/// * The distance being in bounds must not rely on "wrapping around" the
499
- /// address space.
499
+ /// address space.
500
500
///
501
501
/// Note that callers may pass a pair of pointers such that `start >= end`.
502
502
/// In that case, `None` will always be returned.
@@ -534,13 +534,13 @@ impl Two {
534
534
/// * Both `start` and `end` must be valid for reads.
535
535
/// * Both `start` and `end` must point to an initialized value.
536
536
/// * Both `start` and `end` must point to the same allocated object and
537
- /// must either be in bounds or at most one byte past the end of the
538
- /// allocated object.
537
+ /// must either be in bounds or at most one byte past the end of the
538
+ /// allocated object.
539
539
/// * Both `start` and `end` must be _derived from_ a pointer to the same
540
- /// object.
540
+ /// object.
541
541
/// * The distance between `start` and `end` must not overflow `isize`.
542
542
/// * The distance being in bounds must not rely on "wrapping around" the
543
- /// address space.
543
+ /// address space.
544
544
///
545
545
/// Note that callers may pass a pair of pointers such that `start >= end`.
546
546
/// In that case, `None` will always be returned.
@@ -776,13 +776,13 @@ impl Three {
776
776
/// * Both `start` and `end` must be valid for reads.
777
777
/// * Both `start` and `end` must point to an initialized value.
778
778
/// * Both `start` and `end` must point to the same allocated object and
779
- /// must either be in bounds or at most one byte past the end of the
780
- /// allocated object.
779
+ /// must either be in bounds or at most one byte past the end of the
780
+ /// allocated object.
781
781
/// * Both `start` and `end` must be _derived from_ a pointer to the same
782
- /// object.
782
+ /// object.
783
783
/// * The distance between `start` and `end` must not overflow `isize`.
784
784
/// * The distance being in bounds must not rely on "wrapping around" the
785
- /// address space.
785
+ /// address space.
786
786
///
787
787
/// Note that callers may pass a pair of pointers such that `start >= end`.
788
788
/// In that case, `None` will always be returned.
@@ -822,13 +822,13 @@ impl Three {
822
822
/// * Both `start` and `end` must be valid for reads.
823
823
/// * Both `start` and `end` must point to an initialized value.
824
824
/// * Both `start` and `end` must point to the same allocated object and
825
- /// must either be in bounds or at most one byte past the end of the
826
- /// allocated object.
825
+ /// must either be in bounds or at most one byte past the end of the
826
+ /// allocated object.
827
827
/// * Both `start` and `end` must be _derived from_ a pointer to the same
828
- /// object.
828
+ /// object.
829
829
/// * The distance between `start` and `end` must not overflow `isize`.
830
830
/// * The distance being in bounds must not rely on "wrapping around" the
831
- /// address space.
831
+ /// address space.
832
832
///
833
833
/// Note that callers may pass a pair of pointers such that `start >= end`.
834
834
/// In that case, `None` will always be returned.
@@ -986,45 +986,45 @@ mod tests {
986
986
#[ test]
987
987
fn forward_two ( ) {
988
988
crate :: tests:: memchr:: Runner :: new ( 2 ) . forward_iter (
989
- |haystack, needles| {
990
- let n1 = needles. get ( 0 ) . copied ( ) ?;
991
- let n2 = needles. get ( 1 ) . copied ( ) ?;
992
- Some ( Two :: new ( n1, n2) ?. iter ( haystack) . collect ( ) )
989
+ |haystack, needles| match needles {
990
+ & [ n1, n2] => Some ( Two :: new ( n1, n2) ?. iter ( haystack) . collect ( ) ) ,
991
+ _ => None ,
993
992
} ,
994
993
)
995
994
}
996
995
997
996
#[ test]
998
997
fn reverse_two ( ) {
999
998
crate :: tests:: memchr:: Runner :: new ( 2 ) . reverse_iter (
1000
- |haystack, needles| {
1001
- let n1 = needles. get ( 0 ) . copied ( ) ?;
1002
- let n2 = needles. get ( 1 ) . copied ( ) ?;
1003
- Some ( Two :: new ( n1, n2) ?. iter ( haystack) . rev ( ) . collect ( ) )
999
+ |haystack, needles| match needles {
1000
+ & [ n1, n2] => {
1001
+ Some ( Two :: new ( n1, n2) ?. iter ( haystack) . rev ( ) . collect ( ) )
1002
+ }
1003
+ _ => None ,
1004
1004
} ,
1005
1005
)
1006
1006
}
1007
1007
1008
1008
#[ test]
1009
1009
fn forward_three ( ) {
1010
1010
crate :: tests:: memchr:: Runner :: new ( 3 ) . forward_iter (
1011
- |haystack, needles| {
1012
- let n1 = needles . get ( 0 ) . copied ( ) ? ;
1013
- let n2 = needles . get ( 1 ) . copied ( ) ? ;
1014
- let n3 = needles . get ( 2 ) . copied ( ) ? ;
1015
- Some ( Three :: new ( n1 , n2 , n3 ) ? . iter ( haystack ) . collect ( ) )
1011
+ |haystack, needles| match needles {
1012
+ & [ n1 , n2 , n3 ] => {
1013
+ Some ( Three :: new ( n1 , n2 , n3 ) ? . iter ( haystack ) . collect ( ) )
1014
+ }
1015
+ _ => None ,
1016
1016
} ,
1017
1017
)
1018
1018
}
1019
1019
1020
1020
#[ test]
1021
1021
fn reverse_three ( ) {
1022
1022
crate :: tests:: memchr:: Runner :: new ( 3 ) . reverse_iter (
1023
- |haystack, needles| {
1024
- let n1 = needles . get ( 0 ) . copied ( ) ? ;
1025
- let n2 = needles . get ( 1 ) . copied ( ) ? ;
1026
- let n3 = needles . get ( 2 ) . copied ( ) ? ;
1027
- Some ( Three :: new ( n1 , n2 , n3 ) ? . iter ( haystack ) . rev ( ) . collect ( ) )
1023
+ |haystack, needles| match needles {
1024
+ & [ n1 , n2 , n3 ] => Some (
1025
+ Three :: new ( n1 , n2 , n3 ) ? . iter ( haystack ) . rev ( ) . collect ( ) ,
1026
+ ) ,
1027
+ _ => None ,
1028
1028
} ,
1029
1029
)
1030
1030
}
0 commit comments