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