@@ -45,6 +45,8 @@ macro_rules! declare_types {
45
45
} ;
46
46
}
47
47
48
+ use std:: ops:: Deref ;
49
+
48
50
pub ( crate ) use declare_types;
49
51
50
52
/// A set of modifiers.
@@ -64,7 +66,7 @@ impl<S: Default> Default for ModifierSet<S> {
64
66
}
65
67
}
66
68
67
- impl < S : std :: ops :: Deref < Target = str > > ModifierSet < S > {
69
+ impl < S : Deref < Target = str > > ModifierSet < S > {
68
70
/// Convert the underlying string to a slice.
69
71
pub fn as_deref ( & self ) -> ModifierSet < & str > {
70
72
ModifierSet ( & self . 0 )
@@ -103,7 +105,7 @@ impl<S: std::ops::Deref<Target = str>> ModifierSet<S> {
103
105
104
106
/// Iterate over the list of modifiers in an arbitrary order.
105
107
pub fn iter ( & self ) -> impl Iterator < Item = & str > {
106
- self . 0 . split ( '.' ) . filter ( |s| !s . is_empty ( ) )
108
+ self . into_iter ( )
107
109
}
108
110
109
111
/// Whether the set contains the modifier `m`.
@@ -152,9 +154,22 @@ impl<S: std::ops::Deref<Target = str>> ModifierSet<S> {
152
154
}
153
155
}
154
156
155
- impl < ' a > ModifierSet < & ' a str > {
156
- /// Iterate over the list of modifiers with the original lifetime.
157
- pub fn to_iter ( self ) -> impl Iterator < Item = & ' a str > {
158
- self . 0 . split ( '.' ) . filter ( |s| !s. is_empty ( ) )
157
+ impl < ' a , S : Deref < Target = str > > IntoIterator for & ' a ModifierSet < S > {
158
+ type Item = & ' a str ;
159
+ type IntoIter = std:: str:: Split < ' a , char > ;
160
+
161
+ /// Iterate over the list of modifiers in an arbitrary order.
162
+ fn into_iter ( self ) -> Self :: IntoIter {
163
+ self . 0 . split ( '.' )
164
+ }
165
+ }
166
+
167
+ impl < ' a > IntoIterator for ModifierSet < & ' a str > {
168
+ type Item = & ' a str ;
169
+ type IntoIter = std:: str:: Split < ' a , char > ;
170
+
171
+ /// Iterate over the list of modifiers in an arbitrary order.
172
+ fn into_iter ( self ) -> Self :: IntoIter {
173
+ self . 0 . split ( '.' )
159
174
}
160
175
}
0 commit comments