Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate example, point to examples on docs index page #84

Merged
merged 1 commit into from
May 20, 2024
Merged
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
2 changes: 2 additions & 0 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use anyhow::Result;
use backon::ExponentialBuilder;
use backon::Retryable;

// For more examples, please see: https://docs.rs/backon/#examples

async fn fetch() -> Result<String> {
let response = reqwest::get("https://httpbingo.org/unstable?failure_rate=0.7").await?;
if !response.status().is_success() {
Expand Down
2 changes: 2 additions & 0 deletions examples/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use anyhow::Result;
use backon::BlockingRetryable;
use backon::ExponentialBuilder;

// For more examples, please see: https://docs.rs/backon/#examples

fn fetch() -> Result<String> {
Ok("hello, world!".to_string())
}
Expand Down
2 changes: 2 additions & 0 deletions examples/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use anyhow::Result;
use backon::BlockingRetryable;
use backon::ExponentialBuilder;

// For more examples, please see: https://docs.rs/backon/#examples

fn main() -> Result<()> {
let var = 42;
// `f` can use input variables
Expand Down
22 changes: 2 additions & 20 deletions src/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,10 @@ use crate::Backoff;
/// }
/// ```
///
/// # Example
/// # Examples
///
/// ```no_run
/// use anyhow::Result;
/// use backon::ExponentialBuilder;
/// use backon::Retryable;
/// For more examples, please see: [https://docs.rs/backon/#examples](https://docs.rs/backon/#examples)
///
/// async fn fetch() -> Result<String> {
/// Ok(reqwest::get("https://www.rust-lang.org")
/// .await?
/// .text()
/// .await?)
/// }
///
/// #[tokio::main(flavor = "current_thread")]
/// async fn main() -> Result<()> {
/// let content = fetch.retry(&ExponentialBuilder::default()).await?;
/// println!("fetch succeeded: {}", content);
///
/// Ok(())
/// }
/// ```
pub trait Retryable<
B: BackoffBuilder,
T,
Expand Down