diff options
author | Corey Farwell <coreyf@rwell.org> | 2016-01-20 23:30:45 -0500 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2016-01-21 08:38:09 -0500 |
commit | 7be39d725d6d251366d1cbd2566651b011cdb5a3 (patch) | |
tree | 5233aac487e0871823267670b58310a3ab24e8bf /src/decoder | |
parent | 6fe6a15fe526b08010ff3e6acaf52d3665d34d6b (diff) | |
download | milf-rs-7be39d725d6d251366d1cbd2566651b011cdb5a3.tar.gz milf-rs-7be39d725d6d251366d1cbd2566651b011cdb5a3.zip |
Address issues found by rust-clippy
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/rustc_serialize.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/decoder/rustc_serialize.rs b/src/decoder/rustc_serialize.rs index 9d2644e..2f4fb09 100644 --- a/src/decoder/rustc_serialize.rs +++ b/src/decoder/rustc_serialize.rs @@ -10,7 +10,7 @@ impl rustc_serialize::Decoder for Decoder { type Error = DecodeError; fn read_nil(&mut self) -> Result<(), DecodeError> { match self.toml { - Some(Value::String(ref s)) if s.len() == 0 => {} + Some(Value::String(ref s)) if s.is_empty() => {} Some(Value::String(..)) => return Err(self.err(NilTooLong)), ref found => return Err(self.mismatch("string", found)), } @@ -158,7 +158,7 @@ impl rustc_serialize::Decoder for Decoder { Some(Value::Table(..)) => { let ret = try!(f(self)); match self.toml { - Some(Value::Table(ref t)) if t.len() == 0 => {} + Some(Value::Table(ref t)) if t.is_empty() => {} _ => return Ok(ret) } self.toml.take(); @@ -243,7 +243,7 @@ impl rustc_serialize::Decoder for Decoder { match self.toml { Some(Value::Array(ref mut arr)) => { arr.retain(|slot| slot.as_integer() != Some(0)); - if arr.len() != 0 { return Ok(ret) } + if !arr.is_empty() { return Ok(ret) } } _ => return Ok(ret) } @@ -262,12 +262,10 @@ impl rustc_serialize::Decoder for Decoder { }; let mut d = self.sub_decoder(Some(toml), ""); let ret = try!(f(&mut d)); - match d.toml { - Some(toml) => match self.toml { - Some(Value::Array(ref mut arr)) => arr[idx] = toml, - _ => {} - }, - _ => {} + if let Some(toml) = d.toml { + if let Some(Value::Array(ref mut arr)) = self.toml { + arr[idx] = toml; + } } Ok(ret) } @@ -290,7 +288,7 @@ impl rustc_serialize::Decoder for Decoder { let ret = try!(f(self, amt)); let leftover = mem::replace(&mut self.leftover_map, prev_map); self.cur_map = prev_iter; - if leftover.len() > 0 { + if !leftover.is_empty() { self.toml = Some(Value::Table(leftover)); } Ok(ret) @@ -317,9 +315,9 @@ impl rustc_serialize::Decoder for Decoder { if let Some(toml) = d.toml.take() { self.leftover_map.insert(key, toml); } - return ret + ret } - None => return Err(self.err(ExpectedMapElement(idx))), + None => Err(self.err(ExpectedMapElement(idx))), } } |