Skip to content

Commit cc01433

Browse files
authored
Rollup merge of rust-lang#92188 - vacuus:nested-attributes-ext, r=jyn514
rustdoc: Clean up NestedAttributesExt trait/implementation
2 parents e35a4bd + 91fe2d0 commit cc01433

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/librustdoc/clean/types.rs

+15-10
Original file line numberDiff line numberDiff line change
@@ -889,20 +889,25 @@ impl AttributesExt for [ast::Attribute] {
889889
}
890890

891891
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`
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

Comments
 (0)