Remove Pin from Delay trait

This commit is contained in:
Dario Nieuwenhuis 2021-04-14 16:39:08 +02:00
parent f292647066
commit d336a4b38a
2 changed files with 4 additions and 5 deletions

View File

@ -1,12 +1,11 @@
use core::future::Future;
use core::pin::Pin;
pub trait Delay {
type DelayFuture<'a>: Future<Output = ()> + 'a;
/// Future that completes after now + millis
fn delay_ms<'a>(self: Pin<&'a mut Self>, millis: u64) -> Self::DelayFuture<'a>;
fn delay_ms<'a>(&'a mut self, millis: u64) -> Self::DelayFuture<'a>;
/// Future that completes after now + micros
fn delay_us<'a>(self: Pin<&'a mut Self>, micros: u64) -> Self::DelayFuture<'a>;
fn delay_us<'a>(&'a mut self, micros: u64) -> Self::DelayFuture<'a>;
}

View File

@ -23,10 +23,10 @@ impl Delay {
impl crate::traits::delay::Delay for Delay {
type DelayFuture<'a> = impl Future<Output = ()> + 'a;
fn delay_ms<'a>(self: Pin<&'a mut Self>, millis: u64) -> Self::DelayFuture<'a> {
fn delay_ms<'a>(&'a mut self, millis: u64) -> Self::DelayFuture<'a> {
Timer::after(Duration::from_millis(millis))
}
fn delay_us<'a>(self: Pin<&'a mut Self>, micros: u64) -> Self::DelayFuture<'a> {
fn delay_us<'a>(&'a mut self, micros: u64) -> Self::DelayFuture<'a> {
Timer::after(Duration::from_micros(micros))
}
}