Skip to content

Commit

Permalink
Make sensors_by_kind ordered
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Sep 12, 2023
1 parent fe2c235 commit ea841d0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build/i2c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ pub enum Disposition {
Validation,
}

#[derive(Copy, Clone, Deserialize, Debug, PartialEq, Eq, Hash)]
#[derive(
Copy, Clone, Deserialize, Debug, PartialEq, Eq, Hash, Ord, PartialOrd,
)]
#[serde(rename_all = "kebab-case")]
pub enum Sensor {
Temperature,
Expand Down Expand Up @@ -1287,7 +1289,7 @@ impl ConfigGenerator {
let mut all = HashSet::new();

if let Some(p) =
p.into_iter().flatten().find(|&p| !all.insert(p))
p.iter().flatten().find(|&p| !all.insert(p))
{
bail!("phase {p} appears multiple times in {d:?}");
}
Expand Down Expand Up @@ -1482,7 +1484,7 @@ impl ConfigGenerator {
d.device.to_uppercase(),
)?;

let mut sensors_by_kind: HashMap<Sensor, Vec<usize>> = HashMap::new();
let mut sensors_by_kind: BTreeMap<Sensor, Vec<usize>> = BTreeMap::new();
for s in sensors {
sensors_by_kind.entry(s.kind).or_default().push(s.id);
}
Expand Down

0 comments on commit ea841d0

Please sign in to comment.