@@ -1365,16 +1365,17 @@ impl<'a> Iterator for PatternSetIter<'a> {
1365
1365
type Item = PatternID ;
1366
1366
1367
1367
fn next ( & mut self ) -> Option < PatternID > {
1368
- while let Some ( ( index, & yes) ) = self . it . next ( ) {
1368
+ // Only valid 'PatternID' values can be inserted into the set
1369
+ // and construction of the set panics if the capacity would
1370
+ // permit storing invalid pattern IDs. Thus, 'yes' is only true
1371
+ // precisely when 'index' corresponds to a valid 'PatternID'.
1372
+ self . it . by_ref ( ) . find_map ( |( index, & yes) | {
1369
1373
if yes {
1370
- // Only valid 'PatternID' values can be inserted into the set
1371
- // and construction of the set panics if the capacity would
1372
- // permit storing invalid pattern IDs. Thus, 'yes' is only true
1373
- // precisely when 'index' corresponds to a valid 'PatternID'.
1374
- return Some ( PatternID :: new_unchecked ( index) ) ;
1374
+ Some ( PatternID :: new_unchecked ( index) )
1375
+ } else {
1376
+ None
1375
1377
}
1376
- }
1377
- None
1378
+ } )
1378
1379
}
1379
1380
1380
1381
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
@@ -1689,13 +1690,14 @@ impl Anchored {
1689
1690
/// # Ok::<(), Box<dyn std::error::Error>>(())
1690
1691
/// ```
1691
1692
#[ non_exhaustive]
1692
- #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
1693
+ #[ derive( Clone , Copy , Default , Debug , Eq , PartialEq ) ]
1693
1694
pub enum MatchKind {
1694
1695
/// Report all possible matches.
1695
1696
All ,
1696
1697
/// Report only the leftmost matches. When multiple leftmost matches exist,
1697
1698
/// report the match corresponding to the part of the regex that appears
1698
1699
/// first in the syntax.
1700
+ #[ default]
1699
1701
LeftmostFirst ,
1700
1702
// There is prior art in RE2 that shows that we should be able to add
1701
1703
// LeftmostLongest too. The tricky part of it is supporting ungreedy
@@ -1721,12 +1723,6 @@ impl MatchKind {
1721
1723
}
1722
1724
}
1723
1725
1724
- impl Default for MatchKind {
1725
- fn default ( ) -> MatchKind {
1726
- MatchKind :: LeftmostFirst
1727
- }
1728
- }
1729
-
1730
1726
/// An error indicating that a search stopped before reporting whether a
1731
1727
/// match exists or not.
1732
1728
///
0 commit comments