@@ -889,20 +889,25 @@ impl AttributesExt for [ast::Attribute] {
889
889
}
890
890
891
891
crate trait NestedAttributesExt {
892
- /// Returns `true` if the attribute list contains a specific `Word`
893
- fn has_word ( self , word : Symbol ) -> bool ;
892
+ /// Returns `true` if the attribute list contains a specific `word`
893
+ fn has_word ( self , word : Symbol ) -> bool
894
+ where
895
+ Self : std:: marker:: Sized ,
896
+ {
897
+ <Self as NestedAttributesExt >:: get_word_attr ( self , word) . is_some ( )
898
+ }
899
+
900
+ /// Returns `Some(attr)` if the attribute list contains 'attr'
901
+ /// corresponding to a specific `word`
894
902
fn get_word_attr ( self , word : Symbol ) -> Option < ast:: NestedMetaItem > ;
895
903
}
896
904
897
- impl < I : Iterator < Item = ast:: NestedMetaItem > + IntoIterator < Item = ast:: NestedMetaItem > >
898
- NestedAttributesExt for I
905
+ impl < I > NestedAttributesExt for I
906
+ where
907
+ I : IntoIterator < Item = ast:: NestedMetaItem > ,
899
908
{
900
- fn has_word ( self , word : Symbol ) -> bool {
901
- self . into_iter ( ) . any ( |attr| attr. is_word ( ) && attr. has_name ( word) )
902
- }
903
-
904
- fn get_word_attr ( mut self , word : Symbol ) -> Option < ast:: NestedMetaItem > {
905
- self . find ( |attr| attr. is_word ( ) && attr. has_name ( word) )
909
+ fn get_word_attr ( self , word : Symbol ) -> Option < ast:: NestedMetaItem > {
910
+ self . into_iter ( ) . find ( |attr| attr. is_word ( ) && attr. has_name ( word) )
906
911
}
907
912
}
908
913
0 commit comments