diff --git a/src/timer.rs b/src/timer.rs index 5e2308b..ccb636d 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -199,16 +199,18 @@ impl Timer{ Self::Unpaused(timer)=>timer.set_time(time,new_time), } } - pub fn pause(self,time:Time)->Result,Error>{ - match self{ - Self::Paused(_)=>Err(Error::AlreadyPaused), - Self::Unpaused(timer)=>Ok(timer.into_paused(time)), - } + pub fn pause(&mut self,time:Time)->Result<(),Error>{ + *self=match *self{ + Self::Paused(_)=>return Err(Error::AlreadyPaused), + Self::Unpaused(timer)=>Self::Paused(timer.into_paused(time)), + }; + Ok(()) } - pub fn unpause(self,time:Time)->Result,Error>{ - match self{ - Self::Paused(timer)=>Ok(timer.into_unpaused(time)), - Self::Unpaused(_)=>Err(Error::AlreadyUnpaused), - } + pub fn unpause(&mut self,time:Time)->Result<(),Error>{ + *self=match *self{ + Self::Paused(timer)=>Self::Unpaused(timer.into_unpaused(time)), + Self::Unpaused(_)=>return Err(Error::AlreadyUnpaused), + }; + Ok(()) } }