diff --git a/src/de.rs b/src/de.rs index 98b3a60..6c18ae3 100644 --- a/src/de.rs +++ b/src/de.rs @@ -333,7 +333,7 @@ fn build_table_indices<'de>(tables: &[Table<'de>]) -> HashMap> let mut res = HashMap::new(); for (i, table) in tables.iter().enumerate() { let header = table.header.iter().map(|v| v.1.clone()).collect::>(); - 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 let header = table.header.iter().map(|v| v.1.clone()).collect::>(); 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)); } diff --git a/src/ser.rs b/src/ser.rs index 90cfcd7..e115541 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -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(())