diff options
author | Guillermo Ramos | 2025-03-16 13:30:13 +0100 |
---|---|---|
committer | Guillermo Ramos | 2025-03-16 20:00:39 +0100 |
commit | 18e4ca440cf1b9d8d20e3e24bac0c55bbd9efada (patch) | |
tree | ef4b16f7ab0d91bc0e9256c75907d3877be4d74c /src | |
parent | 069e902819955d26adc8045a760c1ccfa4be549e (diff) | |
download | hiccup-18e4ca440cf1b9d8d20e3e24bac0c55bbd9efada.tar.gz |
Add updates
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::fmt; use std::ops::AddAssign; @@ -234,7 +233,7 @@ pub struct PeriodicUpdate { #[derive(Debug, Default, Serialize, Deserialize)] pub struct SimUpdates { periodic: Vec<PeriodicUpdate>, - by_month: HashMap<u32, SimUpdate>, + by_month: Vec<(u32, SimUpdate)>, } impl SimUpdates { @@ -257,8 +256,8 @@ impl SimUpdates { ret.push(*update); } } - if let Some(update) = by_month.get(&month) { - ret.push(*update); + for update in by_month.iter().filter(|(m, _u)| *m == month) { + ret.push(update.1); } // println!(" {self:?}.get({month}) -> {ret:?}"); ret @@ -269,7 +268,7 @@ impl SimUpdates { self.periodic.push(p.clone()); } for (k, v) in other.by_month { - self.by_month.insert(k, v); + self.by_month.push((k, v)); } self } @@ -309,7 +308,7 @@ impl SimUpdate { pub fn at(&self, month: u32) -> SimUpdates { let mut updates = SimUpdates::default(); - updates.by_month.insert(month, *self); + updates.by_month.push((month, *self)); updates } } |