aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorGuillermo Ramos2025-02-16 14:11:44 +0100
committerGuillermo Ramos2025-02-16 19:31:48 +0100
commit472b540de459ade8ce8f9b16b97de06020dede30 (patch)
treebde7c112cd7757bd10d348d5ba41a8d83ee29cda /src/lib.rs
parent87d79dbda299de242aa2a4420df2a447274dc355 (diff)
downloadhiccup-472b540de459ade8ce8f9b16b97de06020dede30.tar.gz
SimUpdates default instead of ::new
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e523ee1..0022703 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -59,7 +59,7 @@ impl<'a> Simulation<'a> {
},
payed_amortized: 0.,
history: vec![],
- updates: SimUpdates::new(),
+ updates: SimUpdates::default(),
}
}
@@ -206,20 +206,13 @@ impl fmt::Display for Quota {
}
}
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct SimUpdates<'a> {
periodically: Vec<(u32, Vec<&'a SimUpdate>)>,
by_month: HashMap<u32, Vec<&'a SimUpdate>>,
}
-// pub type SimUpdates<'a> = HashMap<u32, &'a SimUpdate>;
-impl<'a> SimUpdates<'a> {
- pub fn new() -> Self {
- SimUpdates {
- periodically: vec![],
- by_month: HashMap::new(),
- }
- }
+impl<'a> SimUpdates<'a> {
fn get(&self, month: u32) -> Vec<&'a SimUpdate> {
let SimUpdates {
periodically,
@@ -272,13 +265,13 @@ impl fmt::Display for SimUpdate {
impl SimUpdate {
pub fn every(&self, months: u32) -> SimUpdates {
- let mut updates = SimUpdates::new();
+ let mut updates = SimUpdates::default();
updates.periodically.push((months, vec![self]));
updates
}
pub fn at(&self, month: u32) -> SimUpdates {
- let mut updates = SimUpdates::new();
+ let mut updates = SimUpdates::default();
updates.by_month.insert(month, vec![self]);
updates
}