diff options
| author | Yusuke Tanaka <yusuktan@maguro.dev> | 2021-02-13 01:13:50 +0900 |
|---|---|---|
| committer | Yusuke Tanaka <yusuktan@maguro.dev> | 2021-02-13 01:13:50 +0900 |
| commit | 715c19e75e0e2a88f6c0a5ec8c13ee77737c4798 (patch) | |
| tree | 82f416539abe8293cf9a09fc83bf36fbbfb4eab9 | |
| parent | a118ee2c13cc96ceb27bd5030c1cca1052377604 (diff) | |
| download | rust-715c19e75e0e2a88f6c0a5ec8c13ee77737c4798.tar.gz rust-715c19e75e0e2a88f6c0a5ec8c13ee77737c4798.zip | |
Refactor `get_word_attr` to return only `Option`
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 3 | ||||
| -rw-r--r-- | src/librustdoc/clean/types.rs | 9 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 331bb2a73f9..9a4a9e19e22 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2163,7 +2163,8 @@ fn clean_use_statement( return Vec::new(); } - let (doc_meta_item, please_inline) = import.attrs.lists(sym::doc).get_word_attr(sym::inline); + let doc_meta_item = import.attrs.lists(sym::doc).get_word_attr(sym::inline); + let please_inline = doc_meta_item.is_some(); let pub_underscore = import.vis.node.is_pub() && name == kw::Underscore; if pub_underscore && please_inline { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 754f1c2eeeb..a691819ab77 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -438,7 +438,7 @@ 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; - fn get_word_attr(self, word: Symbol) -> (Option<ast::NestedMetaItem>, bool); + fn get_word_attr(self, word: Symbol) -> Option<ast::NestedMetaItem>; } impl<I: Iterator<Item = ast::NestedMetaItem> + IntoIterator<Item = ast::NestedMetaItem>> @@ -448,11 +448,8 @@ impl<I: Iterator<Item = ast::NestedMetaItem> + IntoIterator<Item = ast::NestedMe self.into_iter().any(|attr| attr.is_word() && attr.has_name(word)) } - fn get_word_attr(mut self, word: Symbol) -> (Option<ast::NestedMetaItem>, bool) { - match self.find(|attr| attr.is_word() && attr.has_name(word)) { - Some(a) => (Some(a), true), - None => (None, false), - } + fn get_word_attr(mut self, word: Symbol) -> Option<ast::NestedMetaItem> { + self.find(|attr| attr.is_word() && attr.has_name(word)) } } |
