system call mod

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

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

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