Apply some Clippy suggestions. (#378)

This commit is contained in:
Bram Geron 2020-02-25 19:08:29 +01:00 committed by GitHub
parent f12a16274b
commit b84615a24c
2 changed files with 5 additions and 5 deletions

View file

@ -333,7 +333,7 @@ fn build_table_indices<'de>(tables: &[Table<'de>]) -> HashMap<Vec<Cow<'de, str>>
let mut res = HashMap::new(); let mut res = HashMap::new();
for (i, table) in tables.iter().enumerate() { for (i, table) in tables.iter().enumerate() {
let header = table.header.iter().map(|v| v.1.clone()).collect::<Vec<_>>(); 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 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<_>>(); let header = table.header.iter().map(|v| v.1.clone()).collect::<Vec<_>>();
for len in 0..=header.len() { for len in 0..=header.len() {
res.entry(header[..len].to_owned()) res.entry(header[..len].to_owned())
.or_insert(Vec::new()) .or_insert_with(Vec::new)
.push(i); .push(i);
} }
} }
@ -680,7 +680,7 @@ impl<'de, 'b> de::Deserializer<'de> for MapVisitor<'de, 'b> {
} }
let table = &mut self.tables[0]; let table = &mut self.tables[0];
let values = table.values.take().expect("table has no values?"); 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)); return Err(self.de.error(self.cur, ErrorKind::EmptyTableKey));
} }
let name = table.header[table.header.len() - 1].1.to_owned(); let name = table.header[table.header.len() - 1].1.to_owned();
@ -1633,7 +1633,7 @@ impl<'a> Deserializer<'a> {
if c == '0' && first { if c == '0' && first {
first_zero = true; first_zero = true;
} else if c.to_digit(radix).is_some() { } else if c.is_digit(radix) {
if !first && first_zero && !allow_leading_zeros { if !first && first_zero && !allow_leading_zeros {
return Err(self.error(at, ErrorKind::NumberInvalid)); return Err(self.error(at, ErrorKind::NumberInvalid));
} }

View file

@ -502,7 +502,7 @@ impl<'a> Serializer<'a> {
State::Array { type_, .. } => type_, State::Array { type_, .. } => type_,
_ => return Ok(()), _ => return Ok(()),
}; };
if let None = prev.get() { if prev.get().is_none() {
prev.set(Some(type_)); prev.set(Some(type_));
} }
Ok(()) Ok(())