Skip to content

Commit

Permalink
Merge pull request #49 from teozkr/feature/boxed-backoff
Browse files Browse the repository at this point in the history
Implement Backoff for Box<B: Backoff>
  • Loading branch information
ihrwein authored Nov 23, 2021
2 parents 472e9bd + 34deb57 commit 0bd4890
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ pub trait Backoff {
fn next_backoff(&mut self) -> Option<Duration>;
}

impl<B: Backoff + ?Sized> Backoff for Box<B> {
fn next_backoff(&mut self) -> Option<Duration> {
let this: &mut B = self;
this.next_backoff()
}

fn reset(&mut self) {
let this: &mut B = self;
this.reset()
}
}

/// Immediately retry the operation.
#[derive(Debug)]
pub struct Zero {}
Expand Down

0 comments on commit 0bd4890

Please sign in to comment.