Skip to content

Commit

Permalink
fix serde impl for zero length unit array
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Dec 1, 2023
1 parent b806f1c commit c575e30
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/diman_unit_system/src/codegen/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Defs {
} else {
(unit_str, 1)
};
let units = #units;
let units: &[(#dimension_type, &str, f64)] = &#units;
let (dimension, _, factor) = units
.iter()
.find(|(_, known_unit_name, _)| &unit == known_unit_name)
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Defs {
where
S: serde::Serializer,
{
let units = #units;
let units: &[(#dimension_type, &str, f64)] = &#units;
if D == #dimension_type::none() {
serializer.#serialize_method(self.0)
} else {
Expand Down Expand Up @@ -300,7 +300,7 @@ impl Defs {
if D == #dimension_type::none() {
serializer.serialize_str(&vec_to_string(self.0))
} else {
let units = #units;
let units: &[(#dimension_type, &str, f64)] = &#units;
let unit_name = units
.iter()
.filter(|(d, _, _)| d == &D)
Expand Down

0 comments on commit c575e30

Please # to comment.