diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index cb4896fbfd23d..fc26b82c974f8 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -879,20 +879,25 @@ impl AttributesExt for [ast::Attribute] { } crate trait NestedAttributesExt { - /// Returns `true` if the attribute list contains a specific `Word` - fn has_word(self, word: Symbol) -> bool; + /// Returns `true` if the attribute list contains a specific `word` + fn has_word(self, word: Symbol) -> bool + where + Self: std::marker::Sized, + { + ::get_word_attr(self, word).is_some() + } + + /// Returns `Some(attr)` if the attribute list contains 'attr' + /// corresponding to a specific `word` fn get_word_attr(self, word: Symbol) -> Option; } -impl + IntoIterator> - NestedAttributesExt for I +impl NestedAttributesExt for I +where + I: IntoIterator, { - fn has_word(self, word: Symbol) -> bool { - self.into_iter().any(|attr| attr.is_word() && attr.has_name(word)) - } - - fn get_word_attr(mut self, word: Symbol) -> Option { - self.find(|attr| attr.is_word() && attr.has_name(word)) + fn get_word_attr(self, word: Symbol) -> Option { + self.into_iter().find(|attr| attr.is_word() && attr.has_name(word)) } }