diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 17 | ||||
-rw-r--r-- | src/main.rs | 2 |
2 files changed, 6 insertions, 13 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 } diff --git a/src/main.rs b/src/main.rs index 80d7ae7..5ca388b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ fn main() { let updates: SimUpdates = Amortize(12_000.).every(12).and(Amortize(30_000.).at(1)); // let mut sim = Simulation::new(200_000., 0.01621, 30); - // let updates: SimUpdates = SimUpdates::new(); + // let updates: SimUpdates = SimUpdates::default(); sim.run(updates); sim.render_table(); |