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

Would you consider providing macros? #44

Open
NickLarsenNZ opened this issue Sep 3, 2021 · 0 comments
Open

Would you consider providing macros? #44

NickLarsenNZ opened this issue Sep 3, 2021 · 0 comments

Comments

@NickLarsenNZ
Copy link

NickLarsenNZ commented Sep 3, 2021

I have used a Python decorator in the past, and wondered if you might consider providing a proc_macro to reduce boiler plate. I'm quit new to proc_macro, but I could give it a try.

examples/retry.rs could become:

#[retry(ExponentialBackoff)]
fn fetch_url(url: &str) -> Result<String, Error<reqwest::Error>> {
    println!("Fetching {}", url);
    let mut resp = reqwest::blocking::get(url)?;

    let mut content = String::new();
    let _ = resp.read_to_string(&mut content);
    Ok(content)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant