diff --git a/Changelog.md b/Changelog.md index 86b9e0f5..91ce25ec 100644 --- a/Changelog.md +++ b/Changelog.md @@ -87,7 +87,7 @@ - docs: add `deserialize_with` example in readme - fix: Skip phonetic run - fix: Fix XLS float parsing error -- docs: Correct MBSC to MBCS in vba.rs (mispelled before) +- docs: Correct MBSC to MBCS in vba.rs (misspelled before) - style: use 2018 edition paths - fix: Add the ability to read formula values from XLSB - fix: support integral date types diff --git a/src/de.rs b/src/de.rs index b6a3d281..16a414fa 100644 --- a/src/de.rs +++ b/src/de.rs @@ -392,10 +392,10 @@ where } fn deserialize_map>(self, visitor: V) -> Result { - if !self.has_headers() { - visitor.visit_seq(self) - } else { + if self.has_headers() { visitor.visit_map(self) + } else { + visitor.visit_seq(self) } } @@ -405,10 +405,10 @@ where _cells: &'static [&'static str], visitor: V, ) -> Result { - if !self.has_headers() { - visitor.visit_seq(self) - } else { + if self.has_headers() { visitor.visit_map(self) + } else { + visitor.visit_seq(self) } } diff --git a/src/xls.rs b/src/xls.rs index 7df58862..80ed0dab 100644 --- a/src/xls.rs +++ b/src/xls.rs @@ -1320,12 +1320,12 @@ fn parse_formula( } } } - if stack.len() != 1 { + if stack.len() == 1 { + Ok(formula) + } else { Err(XlsError::InvalidFormula { stack_size: stack.len(), }) - } else { - Ok(formula) } } diff --git a/src/xlsb.rs b/src/xlsb.rs index c6abd2c1..c4351211 100644 --- a/src/xlsb.rs +++ b/src/xlsb.rs @@ -377,7 +377,7 @@ impl Xlsb { } } - fn worksheet_range_from_path(&mut self, path: String) -> Result, XlsbError> { + fn worksheet_range_from_path(&mut self, path: &str) -> Result, XlsbError> { let mut iter = RecordIter::from_zip(&mut self.zip, &path)?; let mut buf = vec![0; 1024]; let formats = &self.formats; @@ -651,7 +651,7 @@ impl Reader for Xlsb { Some((_, path)) => path.clone(), None => return None, }; - Some(self.worksheet_range_from_path(path)) + Some(self.worksheet_range_from_path(&path)) } /// MS-XLSB 2.1.7.62 @@ -669,7 +669,7 @@ impl Reader for Xlsb { sheets .into_iter() .filter_map(|(name, path)| { - let ws = self.worksheet_range_from_path(path).ok()?; + let ws = self.worksheet_range_from_path(&path).ok()?; Some((name, ws)) }) .collect() @@ -1079,10 +1079,10 @@ fn parse_formula( } } - if stack.len() != 1 { - Err(XlsbError::StackLen) - } else { + if stack.len() == 1 { Ok(formula) + } else { + Err(XlsbError::StackLen) } } diff --git a/src/xlsx.rs b/src/xlsx.rs index 8dc48906..ff425bf7 100644 --- a/src/xlsx.rs +++ b/src/xlsx.rs @@ -68,7 +68,7 @@ pub enum XlsxError { /// There is no column component in the range string RangeWithoutColumnComponent, /// There is no row component in the range string - RangeWithoutRowCompontent, + RangeWithoutRowComponent, /// Unexpected error Unexpected(&'static str), /// Unrecognized data @@ -121,7 +121,7 @@ impl std::fmt::Display for XlsxError { XlsxError::RangeWithoutColumnComponent => { write!(f, "Range is missing the expected column component.") } - XlsxError::RangeWithoutRowCompontent => { + XlsxError::RangeWithoutRowComponent => { write!(f, "Range is missing the expected row component.") } XlsxError::Unexpected(e) => write!(f, "{}", e), @@ -380,7 +380,7 @@ impl Xlsx { Ok(Event::Start(ref e)) if e.local_name().as_ref() == b"definedName" => { if let Some(a) = e .attributes() - .filter_map(|a| a.ok()) + .filter_map(std::result::Result::ok) .find(|a| a.key == QName(b"name")) { let name = a.decode_and_unescape_value(&xml)?.to_string(); @@ -1213,7 +1213,7 @@ fn get_row_and_optional_column(range: &[u8]) -> Result<(u32, Option), XlsxE } let row = row .checked_sub(1) - .ok_or(XlsxError::RangeWithoutRowCompontent)?; + .ok_or(XlsxError::RangeWithoutRowComponent)?; Ok((row, col.checked_sub(1))) }