@@ -889,20 +889,25 @@ impl AttributesExt for [ast::Attribute] {
889889}
890890
891891crate 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`
894902 fn get_word_attr ( self , word : Symbol ) -> Option < ast:: NestedMetaItem > ;
895903}
896904
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 > ,
899908{
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) )
906911 }
907912}
908913
0 commit comments