aboutsummaryrefslogtreecommitdiff
path: root/embassy-time
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-08-31 02:46:52 +0200
committerDario Nieuwenhuis <[email protected]>2022-08-31 03:11:21 +0200
commit8ba421f324f0971b2394f497d8fbbee65847f583 (patch)
tree81c4f1f6d62fdc85f17c466e26d8bb16198a7301 /embassy-time
parentfe08bdf0d81e784c3af642128b91a53514b79a63 (diff)
Do not use cfg_if for embedded-hal-async feature gates.
Old code used `cfg_if!` because rustc still parses code inside disabled cfg's, and Rust stable at that time couldn't parse the new GAT where-clause location. This is not the case anymore.
Diffstat (limited to 'embassy-time')
-rw-r--r--embassy-time/src/delay.rs32
1 files changed, 17 insertions, 15 deletions
diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs
index d010fff98..0a7982963 100644
--- a/embassy-time/src/delay.rs
+++ b/embassy-time/src/delay.rs
@@ -31,26 +31,28 @@ mod eh1 {
31 } 31 }
32} 32}
33 33
34cfg_if::cfg_if! { 34#[cfg(all(feature = "unstable-traits", feature = "nightly"))]
35 if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] { 35mod eha {
36 use crate::Timer; 36 use core::future::Future;
37 use core::future::Future;
38 use futures_util::FutureExt;
39 37
40 impl embedded_hal_async::delay::DelayUs for Delay { 38 use futures_util::FutureExt;
41 type Error = core::convert::Infallible;
42 39
43 type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 40 use super::*;
41 use crate::Timer;
42
43 impl embedded_hal_async::delay::DelayUs for Delay {
44 type Error = core::convert::Infallible;
44 45
45 fn delay_us(&mut self, micros: u32) -> Self::DelayUsFuture<'_> { 46 type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
46 Timer::after(Duration::from_micros(micros as _)).map(Ok) 47
47 } 48 fn delay_us(&mut self, micros: u32) -> Self::DelayUsFuture<'_> {
49 Timer::after(Duration::from_micros(micros as _)).map(Ok)
50 }
48 51
49 type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 52 type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
50 53
51 fn delay_ms(&mut self, millis: u32) -> Self::DelayMsFuture<'_> { 54 fn delay_ms(&mut self, millis: u32) -> Self::DelayMsFuture<'_> {
52 Timer::after(Duration::from_millis(millis as _)).map(Ok) 55 Timer::after(Duration::from_millis(millis as _)).map(Ok)
53 }
54 } 56 }
55 } 57 }
56} 58}