diff options
author | 2023-01-31 22:05:43 +0100 | |
---|---|---|
committer | 2023-02-01 09:10:31 +0100 | |
commit | 2a4218c8ff58a4061d29d311c01ccc97a0143b08 (patch) | |
tree | 31efeed8bbf31ce837eb374cde33859fab60f622 /rtic-time/src/lib.rs | |
parent | 4c95224e7274dc508e6d89304b9f58bf07c40ee6 (diff) | |
download | rtic-2a4218c8ff58a4061d29d311c01ccc97a0143b08.tar.gz rtic-2a4218c8ff58a4061d29d311c01ccc97a0143b08.tar.zst rtic-2a4218c8ff58a4061d29d311c01ccc97a0143b08.zip |
Cleanup common code and clippy fixes
Diffstat (limited to '')
-rw-r--r-- | rtic-time/src/lib.rs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/rtic-time/src/lib.rs b/rtic-time/src/lib.rs index 44fdbcec..5e4457cc 100644 --- a/rtic-time/src/lib.rs +++ b/rtic-time/src/lib.rs @@ -14,13 +14,13 @@ use futures_util::{ future::{select, Either}, pin_mut, }; +use linked_list::{Link, LinkedList}; pub use monotonic::Monotonic; +use rtic_common::dropper::OnDrop; mod linked_list; mod monotonic; -use linked_list::{Link, LinkedList}; - /// Holds a waker and at which time instant this waker shall be awoken. struct WaitingWaker<Mono: Monotonic> { waker: Waker, @@ -264,26 +264,3 @@ impl<Mono: Monotonic> TimerQueue<Mono> { } } } - -struct OnDrop<F: FnOnce()> { - f: core::mem::MaybeUninit<F>, -} - -impl<F: FnOnce()> OnDrop<F> { - pub fn new(f: F) -> Self { - Self { - f: core::mem::MaybeUninit::new(f), - } - } - - #[allow(unused)] - pub fn defuse(self) { - core::mem::forget(self) - } -} - -impl<F: FnOnce()> Drop for OnDrop<F> { - fn drop(&mut self) { - unsafe { self.f.as_ptr().read()() } - } -} |