Skip to content
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![MSRV 1.80.0](https://img.shields.io/badge/MSRV-1.80.0-green?style=flat-square&logo=rust)](https://www.whatrustisit.com)
[![CI Status](https://img.shields.io/github/actions/workflow/status/fast/stacksafe/ci.yml?style=flat-square&logo=github)](https://github.com/fast/stacksafe/actions)

StackSafe enables safe execution of deeply recursive algorithms through intelligent stack management, eliminating the need for manual stack size tuning or complex refactoring to iterative approaches.
StackSafe prevents stack overflows in deeply recursive algorithms by providing intelligent stack management. No more crashes from recursive functions or data structures that exceed the default stack size - StackSafe automatically allocates additional stack space when needed, eliminating the need for manual stack size tuning or complex refactoring to iterative approaches.

## Quick Start

Expand All @@ -16,7 +16,7 @@ Add StackSafe to your `Cargo.toml`:
stacksafe = "0.1"
```

Transform recursive functions with the `#[stacksafe]` attribute:
Transform recursive functions with the `#[stacksafe]` attribute to prevent stack overflow:

```rust
use stacksafe::stacksafe;
Expand All @@ -29,13 +29,13 @@ fn fibonacci(n: u64) -> u64 {
}
}

// Safe for deep recursion
// No stack overflow, even for deep recursion
println!("Fibonacci of 30: {}", fibonacci(30));
```

## Recursive Data Structures

Use `StackSafe<T>` to wrap recursive data structures:
Use `StackSafe<T>` to wrap recursive data structures and prevent stack overflow during traversal:

```rust
use stacksafe::{stacksafe, StackSafe};
Expand Down
2 changes: 1 addition & 1 deletion stacksafe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "stacksafe"
version = "0.1.0"

categories = ["memory-management", "rust-patterns"]
description = "Safe execution of deeply recursive functions with automatic stack management."
description = "Prevent stack overflow in deeply recursive functions with automatic stack management."
documentation = "https://docs.rs/stacksafe"
keywords = ["recursion", "recursive", "stacker", "stack", "overflow"]
readme = "../README.md"
Expand Down
21 changes: 12 additions & 9 deletions stacksafe/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! StackSafe enables safe execution of deeply recursive algorithms through intelligent stack
//! management, eliminating the need for manual stack size tuning or complex refactoring to
//! iterative approaches.
//! StackSafe prevents stack overflows in deeply recursive algorithms by providing intelligent stack
//! management. No more crashes from recursive functions or data structures that exceed the default
//! stack size - StackSafe automatically allocates additional stack space when needed, eliminating
//! the need for manual stack size tuning or complex refactoring to iterative approaches.
//!
//! ## Quick Start
//!
Expand All @@ -11,7 +12,8 @@
//! stacksafe = "0.1"
//! ```
//!
//! Transform recursive functions with the [`#[stacksafe]`](stacksafe) attribute:
//! Transform recursive functions with the [`#[stacksafe]`](stacksafe) attribute to prevent stack
//! overflow:
//!
//! ```rust
//! use stacksafe::stacksafe;
Expand All @@ -24,13 +26,14 @@
//! }
//! }
//!
//! // Safe for deep recursion
//! // No stack overflow, even for deep recursion
//! println!("Fibonacci of 30: {}", fibonacci(30));
//! ```
//!
//! ## Recursive Data Structures
//!
//! Use [`StackSafe<T>`] to wrap recursive data structures:
//! Use [`StackSafe<T>`] to wrap recursive data structures and prevent stack overflow during
//! traversal:
//!
//! ```rust
//! use stacksafe::StackSafe;
Expand Down Expand Up @@ -59,11 +62,11 @@
//!
//! - [`#[stacksafe]`](stacksafe) attribute monitors remaining stack space at function entry points.
//! When available space falls below a threshold (default: 128 KiB), it automatically allocates a
//! new stack segment (default: 2 MiB) and continues execution.
//! new stack segment (default: 2 MiB) and continues execution, preventing stack overflow.
//!
//! - [`StackSafe<T>`] is a wrapper type that transparently implement common traits like [`Clone`],
//! [`Debug`], and [`PartialEq`] with `#[stacksafe]` support, allowing you to use it in recursive
//! data structures without losing functionality.
//! [`Debug`], and [`PartialEq`] with `#[stacksafe]` support, ensuring stack-safe operations on
//! recursive data structures without risking overflow.
//!
//! ## Configuration
//!
Expand Down
Loading