Skip to content

Commit 91fe2d0

Browse files
committed
Clean up NestedAttributesExt trait/implementation
1 parent c09a952 commit 91fe2d0

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
@@ -879,20 +879,25 @@ impl AttributesExt for [ast::Attribute] {
879879
}
880880

881881
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`
884892
fn get_word_attr(self, word: Symbol) -> Option<ast::NestedMetaItem>;
885893
}
886894

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>,
889898
{
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))
896901
}
897902
}
898903

0 commit comments

Comments
 (0)