Skip to content

Commit ceddb77

Browse files
committed
fix: dont need option on sleep duration
1 parent 374d872 commit ceddb77

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

script/src/util/retry.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<T: Future> Retry for T {
2121
pub struct RetryFuture<F> {
2222
inner: F,
2323
tries: u32,
24-
base_delay: Option<Duration>,
24+
base_delay: Duration,
2525
attempts: u32,
2626
sleep: Option<Pin<Box<dyn Future<Output = ()>>>>,
2727
}
@@ -32,7 +32,7 @@ impl<F> RetryFuture<F> {
3232
Self {
3333
inner,
3434
tries,
35-
base_delay: Some(base_delay),
35+
base_delay,
3636
attempts: 0,
3737
sleep: None,
3838
}
@@ -66,11 +66,9 @@ where
6666
return Poll::Ready(Err(e));
6767
}
6868

69-
if let Some(base_delay) = this.base_delay {
70-
this.sleep = Some(Box::pin(tokio::time::sleep(
71-
base_delay * 2_u32.pow(this.attempts),
72-
)));
73-
}
69+
this.sleep = Some(Box::pin(tokio::time::sleep(
70+
this.base_delay * 2_u32.pow(this.attempts),
71+
)));
7472

7573
Poll::Pending
7674
}

0 commit comments

Comments
 (0)