about summary refs log tree commit diff
path: root/src/libserialize
diff options
context:
space:
mode:
authorZack M. Davis <code@zackmdavis.net>2016-07-03 14:38:37 -0700
committerZack M. Davis <code@zackmdavis.net>2016-07-03 16:27:02 -0700
commitd37edef9dd088d953c5e272db37686a338c31778 (patch)
tree294c125abc99a5d3e7d788c2cc0b056ecd35a26e /src/libserialize
parent5e858f34df6ac9ae9d2fbc40c84db9d4bcd29eff (diff)
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.
Diffstat (limited to 'src/libserialize')
-rw-r--r--src/libserialize/json.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 90b2c611603..6c4b6c4506b 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -1764,9 +1764,8 @@ impl<T: Iterator<Item=char>> Parser<T> {
                     return self.parse_array(first);
                 }
                 ParseArrayComma => {
-                    match self.parse_array_comma_or_end() {
-                        Some(evt) => { return evt; }
-                        None => {}
+                    if let Some(evt) = self.parse_array_comma_or_end() {
+                        return evt;
                     }
                 }
                 ParseObject(first) => {
@@ -2583,9 +2582,8 @@ impl<'a, T: Encodable> fmt::Display for AsPrettyJson<'a, T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let mut shim = FormatShim { inner: f };
         let mut encoder = PrettyEncoder::new(&mut shim);
-        match self.indent {
-            Some(n) => encoder.set_indent(n),
-            None => {}
+        if let Some(n) = self.indent {
+            encoder.set_indent(n);
         }
         match self.inner.encode(&mut encoder) {
             Ok(_) => Ok(()),