system call mod

master
Avril 4 years ago
parent b07b68d587
commit 908c520b35
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -44,21 +44,21 @@ impl Unit
fn multiplier(&self) -> u64 {
use lazy_static::lazy_static;
use std::collections::HashMap;
use Unit::*;
lazy_static! {
static ref MUL_TABLE: HashMap<Unit, u64> = {
let mut map = HashMap::with_capacity(8);
map.insert(Second, 1000);
map.insert(Minute, Second.multiplier() * 60);
map.insert(Hour, Minute.multiplier() * 60);
map.insert(Day, Hour.multiplier() * 24);
map.insert(Week, Day.multiplier() * 7);
map.insert(Year, Week.multiplier() * 52);
map.insert(Aeon, Year.multiplier() * 1000000);
map
};
fn calc_table(&self) -> {
use Unit::*;
match self {
Second => 1000,
Minute => Second.multiplier() * 60,
Hour => Minute.multiplier() * 60,
Day => Hour.multiplier() * 24,
Week => Day.multiplier() * 7,
Year => Week.multiplier() * 52,
Aeon => Year.multiplier() * 1000000,
}
}
*MUL_TABLE.get(&self).unwrap()
}
}

@ -0,0 +1,2 @@
use super::*;
Loading…
Cancel
Save