Skip to content

Commit 9161080

Browse files
authored
chore(deps): move futures to dev-deps (#30)
* chore(deps): use futures-core rather than futures * fix(clippy): user new lint unexpected_cfgs * docs: update CHANGELOG * fix(ci): flaky test on windows ci
1 parent 9722f18 commit 9161080

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- N/A
1010

1111
### Changed
12-
- N/A
12+
- Moved the `futures` dependency to `dev-dependencies`. MSRV is now 1.48.
1313

1414
### Deprecated
1515
- N/A

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ categories = ["rust-patterns"]
1313
keywords = ["tokio", "futures", "retry"]
1414

1515
[dependencies]
16-
futures = "0.3"
1716
pin-project-lite = "0.2"
1817

1918
[dependencies.tokio]
2019
package = "tokio"
2120
version = "1"
2221
default-features = false
2322
features = ["rt", "time", "macros", "test-util", "sync"]
23+
24+
[dev-dependencies]
25+
futures = "0.3"

src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
clippy::match_same_arms,
161161
clippy::match_wildcard_for_single_variants,
162162
clippy::mem_forget,
163-
clippy::mismatched_target_os,
164163
clippy::needless_borrow,
165164
clippy::needless_continue,
166165
clippy::option_option,
@@ -175,6 +174,7 @@
175174
clippy::unnested_or_patterns,
176175
clippy::unused_self,
177176
clippy::verbose_file_reads,
177+
unexpected_cfgs,
178178
future_incompatible,
179179
nonstandard_style,
180180
rust_2018_idioms
@@ -186,7 +186,6 @@
186186
use backoff_strategies::{
187187
BackoffStrategy, ExponentialBackoff, FixedBackoff, LinearBackoff, NoBackoff,
188188
};
189-
use futures::ready;
190189
use pin_project_lite::pin_project;
191190
use std::time::Duration;
192191
use std::{
@@ -569,18 +568,19 @@ where
569568
future: (this.make_future)(),
570569
},
571570

572-
RetryStateProj::TimerActive { sleep } => {
573-
ready!(sleep.poll(cx));
574-
RetryState::WaitingForFuture {
571+
RetryStateProj::TimerActive { sleep } => match sleep.poll(cx) {
572+
Poll::Ready(()) => RetryState::WaitingForFuture {
575573
future: (this.make_future)(),
576-
}
577-
}
574+
},
575+
Poll::Pending => return Poll::Pending,
576+
},
578577

579-
RetryStateProj::WaitingForFuture { future } => match ready!(future.poll(cx)) {
580-
Ok(value) => {
578+
RetryStateProj::WaitingForFuture { future } => match future.poll(cx) {
579+
Poll::Pending => return Poll::Pending,
580+
Poll::Ready(Ok(value)) => {
581581
return Poll::Ready(Ok(value));
582582
}
583-
Err(error) => {
583+
Poll::Ready(Err(error)) => {
584584
if *this.attempts_remaining == 0 {
585585
if let Some(on_retry) = &mut this.config.on_retry {
586586
tokio::spawn(on_retry.on_retry(*this.attempt, None, &error));
@@ -724,7 +724,7 @@ mod tests {
724724

725725
// assertions about what the exact times are are very finicky so lets just assert that the
726726
// one without backoff is slower.
727-
assert!(time_with_fixed > time_with_none);
727+
assert!(time_with_fixed >= time_with_none);
728728
}
729729

730730
// `RetryFuture` must be `Send` to be used with `async_trait`

src/on_retry.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
use futures::future::Ready;
2-
use std::{convert::Infallible, future::Future, time::Duration};
1+
use std::{
2+
convert::Infallible,
3+
future::{Future, Ready},
4+
time::Duration,
5+
};
36

47
/// Trait allowing you to run some future when a retry occurs. Could for example to be used for
58
/// logging or other kinds of telemetry.

0 commit comments

Comments
 (0)