1248: embassy-time: add async tick() method to Ticker r=Dirbaio a=kbleeke

Small QOL change so you don't have to add a direct dependency on futures-util to use the Ticker

Co-authored-by: kbleeke <pluth@0t.re>
This commit is contained in:
bors[bot] 2023-02-28 17:12:13 +00:00 committed by GitHub
commit d719f8bc03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ use core::pin::Pin;
use core::task::{Context, Poll, Waker};
use futures_util::future::{select, Either};
use futures_util::{pin_mut, Stream};
use futures_util::{pin_mut, Stream, StreamExt};
use crate::{Duration, Instant};
@ -132,6 +132,11 @@ impl Ticker {
let expires_at = Instant::now() + duration;
Self { expires_at, duration }
}
/// Waits for the next tick
pub async fn next(&mut self) {
<Self as StreamExt>::next(self).await;
}
}
impl Unpin for Ticker {}