diff options
| author | bors <bors@rust-lang.org> | 2016-07-04 02:18:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-04 02:18:46 -0700 |
| commit | d508de6cf7c7bb9b5057ee63432dbbc899209101 (patch) | |
| tree | 972fd7fd823fc411d3d3a175bbae46dee2f6d71b /src/librustdoc/html/render.rs | |
| parent | d98da85c5cfd2546ac711701cecc05b093242a26 (diff) | |
| parent | d37edef9dd088d953c5e272db37686a338c31778 (diff) | |
| download | rust-d508de6cf7c7bb9b5057ee63432dbbc899209101.tar.gz rust-d508de6cf7c7bb9b5057ee63432dbbc899209101.zip | |
Auto merge of #34638 - zackmdavis:if_let_over_none_empty_block_arm, r=jseyfried
prefer `if let` to match with `None => {}` arm in some places
This is a spiritual succesor to #34268 / 8531d581, in which we replaced a
number of matches of None to the unit value with `if let` conditionals
where it was judged that this made for clearer/simpler code (as would be
recommended by Manishearth/rust-clippy's `single_match` lint). The same
rationale applies to matches of None to the empty block.
----
r? @jseyfried
Diffstat (limited to 'src/librustdoc/html/render.rs')
| -rw-r--r-- | src/librustdoc/html/render.rs | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 9f2b33c0282..acf867561a6 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -589,19 +589,16 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { // Attach all orphan methods to the type's definition if the type // has since been learned. for &(did, ref item) in orphan_methods { - match paths.get(&did) { - Some(&(ref fqp, _)) => { - search_index.push(IndexItem { - ty: shortty(item), - name: item.name.clone().unwrap(), - path: fqp[..fqp.len() - 1].join("::"), - desc: Escape(&shorter(item.doc_value())).to_string(), - parent: Some(did), - parent_idx: None, - search_type: get_index_search_type(&item), - }); - }, - None => {} + if let Some(&(ref fqp, _)) = paths.get(&did) { + search_index.push(IndexItem { + ty: shortty(item), + name: item.name.clone().unwrap(), + path: fqp[..fqp.len() - 1].join("::"), + desc: Escape(&shorter(item.doc_value())).to_string(), + parent: Some(did), + parent_idx: None, + search_type: get_index_search_type(&item), + }); } } @@ -2093,15 +2090,12 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, <h2 id='implementors'>Implementors</h2> <ul class='item-list' id='implementors-list'> ")?; - match cache.implementors.get(&it.def_id) { - Some(implementors) => { - for i in implementors { - write!(w, "<li><code>")?; - fmt_impl_for_trait_page(&i.impl_, w)?; - writeln!(w, "</code></li>")?; - } + if let Some(implementors) = cache.implementors.get(&it.def_id) { + for i in implementors { + write!(w, "<li><code>")?; + fmt_impl_for_trait_page(&i.impl_, w)?; + writeln!(w, "</code></li>")?; } - None => {} } write!(w, "</ul>")?; write!(w, r#"<script type="text/javascript" async |
