From 304d2ce9de61351ff2796f41e3994efe64a81d85 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Thu, 26 Mar 2020 03:34:45 -0400 Subject: [PATCH] more from case study --- src/case_study.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/case_study.rs b/src/case_study.rs index 6724a84..d67bd6d 100644 --- a/src/case_study.rs +++ b/src/case_study.rs @@ -113,6 +113,29 @@ impl Active { event_attr!(id, Uuid, id); } + +impl From> for Active { + fn from(pending: Event) -> Active { + Active::Pending(pending) + } +} + +macro_rules! from_event { + ($t:ty, $variant:ident) => { + impl From> for Active { + fn from(event: Event<$t>) -> Active { + Active::$variant(event) + } + } + } +} + +//from_event!(Pending, Pending); +from_event!(Sending, Sending); +from_event!(Sent, Sent); +from_event!(Ack, Acked); +from_event!(Finished, FinishedNoAck); + #[allow(unused)] #[cfg(test)] mod tests {