Skip to content

Commit 4cf9125

Browse files
committed
run cargo fmt
1 parent 5d737ca commit 4cf9125

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

src/delay.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ impl Delay {
4444
pub(crate) fn new_handle(at: Instant, handle: TimerHandle) -> Delay {
4545
let inner = match handle.inner.upgrade() {
4646
Some(i) => i,
47-
None => {
48-
return Delay {
49-
state: None,
50-
}
51-
}
47+
None => return Delay { state: None },
5248
};
5349
let state = Arc::new(Node::new(ScheduledTimer {
5450
at: Mutex::new(Some(at)),
@@ -62,15 +58,11 @@ impl Delay {
6258
// timer, meaning that we'll want to immediately return an error from
6359
// `poll`.
6460
if inner.list.push(&state).is_err() {
65-
return Delay {
66-
state: None,
67-
};
61+
return Delay { state: None };
6862
}
6963

7064
inner.waker.wake();
71-
Delay {
72-
state: Some(state),
73-
}
65+
Delay { state: Some(state) }
7466
}
7567

7668
/// Resets this timeout to an new timeout which will fire at the time

src/delay_wasm.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,35 @@
22
33
use gloo_timers::future::TimeoutFuture;
44
use send_wrapper::SendWrapper;
5-
use std::{time::Duration, pin::Pin, task::{Context, Poll}, future::Future};
5+
use std::{
6+
future::Future,
7+
pin::Pin,
8+
task::{Context, Poll},
9+
time::Duration,
10+
};
611

712
/// A version of `Delay` that works on wasm.
813
#[derive(Debug)]
914
pub struct Delay(SendWrapper<TimeoutFuture>);
1015

1116
impl Delay {
12-
/// Creates a new future which will fire at `dur` time into the future.
13-
#[inline]
14-
pub fn new(dur: Duration) -> Delay {
15-
Self(
16-
SendWrapper::new(TimeoutFuture::new(dur.as_millis() as u32))
17-
)
18-
}
17+
/// Creates a new future which will fire at `dur` time into the future.
18+
#[inline]
19+
pub fn new(dur: Duration) -> Delay {
20+
Self(SendWrapper::new(TimeoutFuture::new(dur.as_millis() as u32)))
21+
}
1922

20-
/// Resets the timeout. Panics on wasm.
21-
#[inline]
22-
pub fn reset(&mut self, at: Duration) {
23-
*self = Delay::new(at);
24-
}
23+
/// Resets the timeout. Panics on wasm.
24+
#[inline]
25+
pub fn reset(&mut self, at: Duration) {
26+
*self = Delay::new(at);
27+
}
2528
}
2629

2730
impl Future for Delay {
28-
type Output = ();
31+
type Output = ();
2932

30-
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
31-
Pin::new(&mut *Pin::into_inner(self).0).poll(cx)
32-
}
33+
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
34+
Pin::new(&mut *Pin::into_inner(self).0).poll(cx)
35+
}
3336
}

0 commit comments

Comments
 (0)