@@ -45,6 +45,8 @@ macro_rules! declare_types {
4545 } ;
4646}
4747
48+ use std:: ops:: Deref ;
49+
4850pub ( crate ) use declare_types;
4951
5052/// A set of modifiers.
@@ -64,7 +66,7 @@ impl<S: Default> Default for ModifierSet<S> {
6466 }
6567}
6668
67- impl < S : std :: ops :: Deref < Target = str > > ModifierSet < S > {
69+ impl < S : Deref < Target = str > > ModifierSet < S > {
6870 /// Convert the underlying string to a slice.
6971 pub fn as_deref ( & self ) -> ModifierSet < & str > {
7072 ModifierSet ( & self . 0 )
@@ -103,7 +105,7 @@ impl<S: std::ops::Deref<Target = str>> ModifierSet<S> {
103105
104106 /// Iterate over the list of modifiers in an arbitrary order.
105107 pub fn iter ( & self ) -> impl Iterator < Item = & str > {
106- self . 0 . split ( '.' ) . filter ( |s| !s . is_empty ( ) )
108+ self . into_iter ( )
107109 }
108110
109111 /// Whether the set contains the modifier `m`.
@@ -152,9 +154,22 @@ impl<S: std::ops::Deref<Target = str>> ModifierSet<S> {
152154 }
153155}
154156
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 ( '.' )
159174 }
160175}
0 commit comments