From 068a0594ddc0741587bc5684cbfbbe7a1e57f1a1 Mon Sep 17 00:00:00 2001 From: andylokandy Date: Sat, 7 Jun 2025 12:52:57 +0800 Subject: [PATCH] chore: update readme --- README.md | 8 ++++---- stacksafe/Cargo.toml | 2 +- stacksafe/src/lib.rs | 21 ++++++++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d30ea50..7a22722 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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; @@ -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` to wrap recursive data structures: +Use `StackSafe` to wrap recursive data structures and prevent stack overflow during traversal: ```rust use stacksafe::{stacksafe, StackSafe}; diff --git a/stacksafe/Cargo.toml b/stacksafe/Cargo.toml index 8dd5f23..c996892 100644 --- a/stacksafe/Cargo.toml +++ b/stacksafe/Cargo.toml @@ -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" diff --git a/stacksafe/src/lib.rs b/stacksafe/src/lib.rs index 7e0a158..8cdf015 100644 --- a/stacksafe/src/lib.rs +++ b/stacksafe/src/lib.rs @@ -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 //! @@ -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; @@ -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`] to wrap recursive data structures: +//! Use [`StackSafe`] to wrap recursive data structures and prevent stack overflow during +//! traversal: //! //! ```rust //! use stacksafe::StackSafe; @@ -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`] 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 //!