Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dcchut/async-recursion
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.3
Choose a base ref
...
head repository: dcchut/async-recursion
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.4
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 18, 2023

  1. Copy the full SHA
    be0d505 View commit details
  2. v1.0.4

    dcchut committed Mar 18, 2023
    Copy the full SHA
    3123582 View commit details
Showing with 8 additions and 12 deletions.
  1. +1 −1 Cargo.toml
  2. +7 −11 src/lib.rs
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "async-recursion"
version = "1.0.3"
version = "1.0.4"
authors = ["Robert Usher <266585+dcchut@users.noreply.github.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
18 changes: 7 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
//!
//! [![Latest version](https://img.shields.io/crates/v/async-recursion)](https://crates.io/crates/async-recursion)
//! [![crates.io downloads](https://img.shields.io/crates/d/async_recursion)](https://crates.io/crates/async-recursion)
//! [![Build Status](https://img.shields.io/github/workflow/status/dcchut/async-recursion/Push%20action/master)](https://github.com/dcchut/async-recursion/actions)
//! [![Build Status](https://img.shields.io/github/actions/workflow/status/dcchut/async-recursion/ci.yml?branch=master)](https://github.com/dcchut/async-recursion/actions)
//! ![Apache/MIT2.0 License](https://img.shields.io/crates/l/async-recursion)
//!
//! Procedural macro for recursive async functions.
@@ -13,12 +13,10 @@
//! ## Motivation
//! Consider the following recursive implementation of the fibonacci numbers:
//!
//! ```rust,ignore
//! async fn fib(n : u32) -> u64 {
//! ```rust,compile_fail
//! async fn fib(n : u32) -> u32 {
//! match n {
//! 0 => panic!("zero is not a valid argument to fib()!"),
//! 1 | 2 => 1,
//! 3 => 2,
//! 0 | 1 => 1,
//! _ => fib(n-1).await + fib(n-2).await
//! }
//! }
@@ -30,7 +28,7 @@
//! error[E0733]: recursion in an `async fn` requires boxing
//! --> src/main.rs:1:26
//! |
//! 1 | async fn fib(n : u32) -> u64 {
//! 1 | async fn fib(n : u32) -> u32 {
//! | ^^^ recursive `async fn`
//! |
//! = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`.
@@ -46,11 +44,9 @@
//! use async_recursion::async_recursion;
//!
//! #[async_recursion]
//! async fn fib(n : u32) -> u64 {
//! async fn fib(n : u32) -> u32 {
//! match n {
//! 0 => panic!("zero is not a valid argument to fib()!"),
//! 1 | 2 => 1,
//! 3 => 2,
//! 0 | 1 => 1,
//! _ => fib(n-1).await + fib(n-2).await
//! }
//! }