From 46fa862e04bc43311ba79ef3db70abf9014b9104 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Sun, 3 Feb 2019 05:45:35 -0600 Subject: bringing to 2018 --- src/modules/construction.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/modules/construction.rs') diff --git a/src/modules/construction.rs b/src/modules/construction.rs index 46ddbb1..f55a2fb 100644 --- a/src/modules/construction.rs +++ b/src/modules/construction.rs @@ -1,5 +1,5 @@ +use crate::modules::types::ModuleType; use std::time::SystemTime; -use modules::types::ModuleType; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub enum ConstructionStatus { @@ -8,26 +8,32 @@ pub enum ConstructionStatus { Constructed, } -#[derive(Serialize, Deserialize, Debug, Clone)] +impl Default for ConstructionStatus { + fn default() -> Self { + ConstructionStatus::None + } +} + +#[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct Construction { - pub status : ConstructionStatus, - construction : Option, - time : u64, - start : Option, + pub status: ConstructionStatus, + construction: Option, + time: u64, + start: Option, } impl Construction { pub fn new() -> Construction { Construction { - status : ConstructionStatus::None, - construction : None, - time : 5, - start : None, + status: ConstructionStatus::None, + construction: None, + time: 5, + start: None, } } pub fn process(&mut self) { - if let Some(timer) = self.start.clone() { + if let Some(timer) = self.start { if timer.elapsed().unwrap().as_secs() > self.time { self.start = Some(SystemTime::now()); self.status = ConstructionStatus::Constructed; -- cgit v1.2.3