1
Fork 0

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.
This commit is contained in:
Zack M. Davis 2016-07-03 14:38:37 -07:00
parent 5e858f34df
commit d37edef9dd
47 changed files with 213 additions and 347 deletions

View file

@ -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(()),