time: Fix nighly feature compilation after upgrade to embedded-hal-async

0.2.0-alpha.0
This commit is contained in:
Gabriel Smith 2022-11-27 17:59:01 -05:00
parent 4d84b5469e
commit aedcc472c9
2 changed files with 6 additions and 13 deletions

View File

@ -33,26 +33,18 @@ mod eh1 {
#[cfg(all(feature = "unstable-traits", feature = "nightly"))] #[cfg(all(feature = "unstable-traits", feature = "nightly"))]
mod eha { mod eha {
use core::future::Future;
use futures_util::FutureExt;
use super::*; use super::*;
use crate::Timer; use crate::Timer;
impl embedded_hal_async::delay::DelayUs for Delay { impl embedded_hal_async::delay::DelayUs for Delay {
type Error = core::convert::Infallible; type Error = core::convert::Infallible;
type DelayUsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; async fn delay_us(&mut self, micros: u32) -> Result<(), Self::Error> {
Ok(Timer::after(Duration::from_micros(micros as _)).await)
fn delay_us(&mut self, micros: u32) -> Self::DelayUsFuture<'_> {
Timer::after(Duration::from_micros(micros as _)).map(Ok)
} }
type DelayMsFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; async fn delay_ms(&mut self, millis: u32) -> Result<(), Self::Error> {
Ok(Timer::after(Duration::from_millis(millis as _)).await)
fn delay_ms(&mut self, millis: u32) -> Self::DelayMsFuture<'_> {
Timer::after(Duration::from_millis(millis as _)).map(Ok)
} }
} }
} }

View File

@ -1,5 +1,6 @@
#![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)] #![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)]
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))] #![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
#![cfg_attr(feature = "nightly", allow(incomplete_features))]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
#![allow(clippy::new_without_default)] #![allow(clippy::new_without_default)]
#![warn(missing_docs)] #![warn(missing_docs)]