๐Ÿ“ฆ orlp / recursive

Easy recursion in Rust, without stack overflows.

โ˜… 36 stars โ‘‚ 4 forks ๐Ÿ‘ 36 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/orlp/recursive.git
HTTPS git clone https://github.com/orlp/recursive.git
SSH git clone git@github.com:orlp/recursive.git
CLI gh repo clone orlp/recursive
Orson Peters Orson Peters Version 0.1.1. f6863bc 1 years ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ src
๐Ÿ“ tests
๐Ÿ“„ .gitignore
๐Ÿ“„ Cargo.toml
๐Ÿ“„ LICENSE
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Recursive

With recursive you can easily make (indirectly) recursive functions without worrying about stack overflows by marking them as #[recursive]:

use recursive::recursive;

#[recursive]
fn sum(nums: &[u64]) -> u64 {
    if let Some((head, tail)) = nums.split_first() {
        head + sum(tail)
    } else {
        0
    }
}

Functions marked with #[recursive] will automatically grow the stack size if it is too small when called. See the crate docs for details.

License

recursive is licensed under the MIT license.