From 0caf908c7827f6ab4423cb0888c90a3332719b86 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 15 Apr 2021 20:28:10 -0600 Subject: [PATCH] Remove unused timer module --- zed/src/lib.rs | 1 - zed/src/timer.rs | 42 ------------------------------------------ 2 files changed, 43 deletions(-) delete mode 100644 zed/src/timer.rs diff --git a/zed/src/lib.rs b/zed/src/lib.rs index 16307bc19a671de723d02bd12410506397dceeec..9bf663d0766dd493eb56c505b2c00ab8c1c6d4ac 100644 --- a/zed/src/lib.rs +++ b/zed/src/lib.rs @@ -9,7 +9,6 @@ mod sum_tree; mod test; mod throttle; mod time; -mod timer; mod util; pub mod watch; pub mod workspace; diff --git a/zed/src/timer.rs b/zed/src/timer.rs deleted file mode 100644 index de3f9e17b0104ccd21d0eebc87e83897f9785354..0000000000000000000000000000000000000000 --- a/zed/src/timer.rs +++ /dev/null @@ -1,42 +0,0 @@ -use smol::prelude::*; -use std::{ - pin::Pin, - task::Poll, - time::{Duration, Instant}, -}; - -pub struct Repeat { - timer: smol::Timer, - period: Duration, -} - -impl Stream for Repeat { - type Item = Instant; - - fn poll_next( - mut self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> Poll> { - match self.as_mut().timer().poll(cx) { - Poll::Ready(instant) => { - let period = self.as_ref().period; - self.as_mut().timer().set_after(period); - Poll::Ready(Some(instant)) - } - Poll::Pending => Poll::Pending, - } - } -} - -impl Repeat { - fn timer(self: std::pin::Pin<&mut Self>) -> Pin<&mut smol::Timer> { - unsafe { self.map_unchecked_mut(|s| &mut s.timer) } - } -} - -pub fn repeat(period: Duration) -> Repeat { - Repeat { - timer: smol::Timer::after(period), - period, - } -}