Skip to content

Commit 1ada63b

Browse files
committed
Fix up doctests and bench builds
1 parent 0abf7e6 commit 1ada63b

File tree

2 files changed

+6
-55
lines changed

2 files changed

+6
-55
lines changed

benches/support/tokiort.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Timer for TokioTimer {
3838
}
3939

4040
fn reset(&self, sleep: &mut Pin<Box<dyn Sleep>>, new_deadline: Instant) {
41-
if let Some(sleep) = sleep.as_mut().downcast_mut_pin::<TokioSleep>() {
41+
if let Some(sleep) = sleep.as_mut().downcast_mut_pin::<tokio::time::Sleep>() {
4242
sleep.reset(new_deadline.into())
4343
}
4444
}
@@ -59,30 +59,7 @@ where
5959
}
6060
}
6161

62-
// Use TokioSleep to get tokio::time::Sleep to implement Unpin.
63-
// see https://docs.rs/tokio/latest/tokio/time/struct.Sleep.html
64-
pin_project! {
65-
pub(crate) struct TokioSleep {
66-
#[pin]
67-
pub(crate) inner: tokio::time::Sleep,
68-
}
69-
}
70-
71-
impl Future for TokioSleep {
72-
type Output = ();
73-
74-
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
75-
self.project().inner.poll(cx)
76-
}
77-
}
78-
79-
impl TokioSleep {
80-
pub fn reset(self: Pin<&mut Self>, deadline: Instant) {
81-
self.project().inner.as_mut().reset(deadline.into());
82-
}
83-
}
84-
85-
pin_project! {
62+
pin_project_lite::pin_project! {
8663
#[derive(Debug)]
8764
pub struct TokioIo<T> {
8865
#[pin]

src/rt/timer.rs

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Provides a timer trait with timer-like functions
22
//!
33
//! Example using tokio timer:
4+
//!
45
//! ```rust
56
//! use std::{
67
//! future::Future,
@@ -17,46 +18,19 @@
1718
//!
1819
//! impl Timer for TokioTimer {
1920
//! fn sleep(&self, duration: Duration) -> Pin<Box<dyn Sleep>> {
20-
//! Box::pin(TokioSleep {
21-
//! inner: tokio::time::sleep(duration),
22-
//! })
21+
//! Box::pin(tokio::time::sleep(duration))
2322
//! }
2423
//!
2524
//! fn sleep_until(&self, deadline: Instant) -> Pin<Box<dyn Sleep>> {
26-
//! Box::pin(TokioSleep {
27-
//! inner: tokio::time::sleep_until(deadline.into()),
28-
//! })
25+
//! Box::pin(tokio::time::sleep_until(deadline.into()))
2926
//! }
3027
//!
3128
//! fn reset(&self, sleep: &mut Pin<Box<dyn Sleep>>, new_deadline: Instant) {
32-
//! if let Some(sleep) = sleep.as_mut().downcast_mut_pin::<TokioSleep>() {
29+
//! if let Some(sleep) = sleep.as_mut().downcast_mut_pin::<tokio::time::Sleep>() {
3330
//! sleep.reset(new_deadline.into())
3431
//! }
3532
//! }
3633
//! }
37-
//!
38-
//! pin_project! {
39-
//! pub(crate) struct TokioSleep {
40-
//! #[pin]
41-
//! pub(crate) inner: tokio::time::Sleep,
42-
//! }
43-
//! }
44-
//!
45-
//! impl Future for TokioSleep {
46-
//! type Output = ();
47-
//!
48-
//! fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
49-
//! self.project().inner.poll(cx)
50-
//! }
51-
//! }
52-
//!
53-
//! impl Sleep for TokioSleep {}
54-
//!
55-
//! impl TokioSleep {
56-
//! pub fn reset(self: Pin<&mut Self>, deadline: Instant) {
57-
//! self.project().inner.as_mut().reset(deadline.into());
58-
//! }
59-
//! }
6034
//! ````
6135
6236
use std::{

0 commit comments

Comments
 (0)