diff options
author | Bram Geron <bram@bram.xyz> | 2020-02-25 19:08:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-25 12:08:29 -0600 |
commit | 7a43ac9e9c28afec8414f6d924024f5d33fe8fa2 (patch) | |
tree | 5dbc73b028b4868cd60a1156907e9c2f4b6f48b1 | |
parent | d99f5665b420f570c4aa26602360f7d5eaee1dc9 (diff) | |
download | milf-rs-7a43ac9e9c28afec8414f6d924024f5d33fe8fa2.tar.gz milf-rs-7a43ac9e9c28afec8414f6d924024f5d33fe8fa2.zip |
Apply some Clippy suggestions. (#378)
-rw-r--r-- | src/de.rs | 8 | ||||
-rw-r--r-- | src/ser.rs | 2 |
2 files changed, 5 insertions, 5 deletions
@@ -333,7 +333,7 @@ fn build_table_indices<'de>(tables: &[Table<'de>]) -> HashMap<Vec<Cow<'de, str>> let mut res = HashMap::new(); for (i, table) in tables.iter().enumerate() { let header = table.header.iter().map(|v| v.1.clone()).collect::<Vec<_>>(); - res.entry(header).or_insert(Vec::new()).push(i); + res.entry(header).or_insert_with(Vec::new).push(i); } res } @@ -359,7 +359,7 @@ fn build_table_pindices<'de>(tables: &[Table<'de>]) -> HashMap<Vec<Cow<'de, str> let header = table.header.iter().map(|v| v.1.clone()).collect::<Vec<_>>(); for len in 0..=header.len() { res.entry(header[..len].to_owned()) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push(i); } } @@ -680,7 +680,7 @@ impl<'de, 'b> de::Deserializer<'de> for MapVisitor<'de, 'b> { } let table = &mut self.tables[0]; let values = table.values.take().expect("table has no values?"); - if table.header.len() == 0 { + if table.header.is_empty() { return Err(self.de.error(self.cur, ErrorKind::EmptyTableKey)); } let name = table.header[table.header.len() - 1].1.to_owned(); @@ -1633,7 +1633,7 @@ impl<'a> Deserializer<'a> { if c == '0' && first { first_zero = true; - } else if c.to_digit(radix).is_some() { + } else if c.is_digit(radix) { if !first && first_zero && !allow_leading_zeros { return Err(self.error(at, ErrorKind::NumberInvalid)); } @@ -502,7 +502,7 @@ impl<'a> Serializer<'a> { State::Array { type_, .. } => type_, _ => return Ok(()), }; - if let None = prev.get() { + if prev.get().is_none() { prev.set(Some(type_)); } Ok(()) |