diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -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 } |