un/pause mutate self instead of taking ownership (uses Copy)
This commit is contained in:
parent
d58af1f2b2
commit
a98b71f0da
24
src/timer.rs
24
src/timer.rs
@ -199,16 +199,18 @@ impl<T:TimerState> Timer<T>{
|
|||||||
Self::Unpaused(timer)=>timer.set_time(time,new_time),
|
Self::Unpaused(timer)=>timer.set_time(time,new_time),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn pause(self,time:Time)->Result<TimerFixed<T,Paused>,Error>{
|
pub fn pause(&mut self,time:Time)->Result<(),Error>{
|
||||||
match self{
|
*self=match *self{
|
||||||
Self::Paused(_)=>Err(Error::AlreadyPaused),
|
Self::Paused(_)=>return Err(Error::AlreadyPaused),
|
||||||
Self::Unpaused(timer)=>Ok(timer.into_paused(time)),
|
Self::Unpaused(timer)=>Self::Paused(timer.into_paused(time)),
|
||||||
}
|
};
|
||||||
}
|
Ok(())
|
||||||
pub fn unpause(self,time:Time)->Result<TimerFixed<T,Unpaused>,Error>{
|
}
|
||||||
match self{
|
pub fn unpause(&mut self,time:Time)->Result<(),Error>{
|
||||||
Self::Paused(timer)=>Ok(timer.into_unpaused(time)),
|
*self=match *self{
|
||||||
Self::Unpaused(_)=>Err(Error::AlreadyUnpaused),
|
Self::Paused(timer)=>Self::Unpaused(timer.into_unpaused(time)),
|
||||||
}
|
Self::Unpaused(_)=>return Err(Error::AlreadyUnpaused),
|
||||||
|
};
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user