From 270663e5297926d9d8459cb6e9d587981ed272e9 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 31 Jul 2024 20:59:31 -0700 Subject: [PATCH] Timer constructors & traits --- src/timer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/timer.rs b/src/timer.rs index 931cfac..976f317 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -176,11 +176,18 @@ impl std::fmt::Display for Error{ impl std::error::Error for Error{} //wrapper type which holds type state internally +#[derive(Clone,Debug)] pub enum Timer{ Paused(TimerFixed), Unpaused(TimerFixed), } impl Timer{ + pub fn paused(time:Time,new_time:Time)->Self{ + Self::Paused(TimerFixed::new(time,new_time)) + } + pub fn unpaused(time:Time,new_time:Time)->Self{ + Self::Unpaused(TimerFixed::new(time,new_time)) + } pub fn time(&self,time:Time)->Time{ match self{ Self::Paused(timer)=>timer.time(time),