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:
parent
5e858f34df
commit
d37edef9dd
47 changed files with 213 additions and 347 deletions
|
@ -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(()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue