Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ travis-ci = { repository = "ihrwein/backoff" }
[dependencies]
async_std_1 = { package = "async-std", version = "1.9", optional = true }
futures-core = { version = "0.3.8", default-features = false, optional = true }
instant = "0.1"
instant = { version = "0.1", optional = true }
pin-project-lite = { version = "0.2.7", optional = true }
rand = "0.8"
getrandom = "0.2"
Expand All @@ -32,8 +32,9 @@ tokio_1 = { package = "tokio", version = "1.0", features = ["macros", "time", "r
futures-executor = "0.3"

[features]
default = []
wasm-bindgen = ["instant/wasm-bindgen", "getrandom/js"]
default = ["instant"]
instant = ["dep:instant"]
wasm-bindgen = ["instant", "instant/wasm-bindgen", "getrandom/js"]
futures = ["futures-core", "pin-project-lite"]
tokio = ["futures", "tokio_1"]
async-std = ["futures", "async_std_1"]
Expand Down
2 changes: 1 addition & 1 deletion src/clock.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use instant::Instant;
use crate::instant::Instant;

/// Clock returns the current time.
pub trait Clock {
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::error;
use std::fmt;

use instant::Duration;
use std::time::Duration;

/// Error is the error value in an operation's
/// result.
Expand Down
2 changes: 1 addition & 1 deletion src/exponential.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use instant::Instant;
use std::marker::PhantomData;
use std::time::Duration;

use crate::backoff::Backoff;
use crate::clock::Clock;
use crate::default;
use crate::instant::Instant;

#[derive(Debug)]
pub struct ExponentialBackoff<C> {
Expand Down
4 changes: 4 additions & 0 deletions src/instant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[cfg(feature = "instant")]
pub use instant::Instant;
#[cfg(not(feature = "instant"))]
pub use std::time::Instant;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ mod clock;
pub mod default;
mod error;
pub mod exponential;
pub mod instant;

#[cfg(feature = "futures")]
#[cfg_attr(docsrs, doc(cfg(feature = "futures")))]
Expand Down
3 changes: 1 addition & 2 deletions tests/exponential.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
extern crate backoff;
extern crate instant;

use backoff::backoff::Backoff;
use backoff::exponential::ExponentialBackoff;
use backoff::instant::Instant;
use backoff::{Clock, SystemClock};

use instant::Instant;
use std::cell::RefCell;
use std::time::Duration;

Expand Down