44 lines
830 B
Rust
44 lines
830 B
Rust
use net::Db;
|
|
// Db Commons
|
|
use failure::Error;
|
|
|
|
// use game::{game_global_startup};
|
|
|
|
pub fn startup(db: Db) -> Result<(), Error> {
|
|
let mut tx = db.transaction()?;
|
|
|
|
info!("running startup fns");
|
|
|
|
// game_global_startup(&mut tx)?;
|
|
|
|
match tx.commit() {
|
|
Ok(_) => {
|
|
info!("startup processes completed");
|
|
Ok(())
|
|
},
|
|
Err(e) => Err(format_err!("failed to commit startup tx {:?}", e)),
|
|
}
|
|
}
|
|
|
|
pub trait IntPct {
|
|
fn pct(self, pct: u64) -> u64;
|
|
}
|
|
|
|
impl IntPct for u64 {
|
|
fn pct(self, pct: u64) -> u64 {
|
|
self * pct / 100
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn int_pct_test() {
|
|
assert_eq!(100.pct(110), 110);
|
|
assert_eq!(100.pct(50), 50);
|
|
assert_eq!(1.pct(200), 2);
|
|
assert_eq!(1.pct(50), 0);
|
|
}
|
|
} |