autowrap 1.0.1

Ergonomic smart pointer and interior mutability extensions
Documentation
  • Coverage
  • 83.33%
    5 out of 6 items documented0 out of 5 items with examples
  • Size
  • Source code size: 7.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.07 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • FreeMan271828/auto-wrap
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • FreeMan271828

Auto_Wrap

Auto_Wrap is a Rust trait that provides convenient methods to wrap any Sized type into common smart pointer and interior mutability types, such as Cell, RefCell, Rc, Arc, and Mutex. It is designed for ergonomic usage with minimal overhead and conditional feature support for threading.

Features

  • Cell Wrapper: Wrap a Copy type into a Cell for interior mutability.
  • RefCell Wrapper: Wrap a type into a RefCell for single-threaded interior mutability (std feature required).
  • Rc Wrapper: Wrap a type into an Rc for reference-counted shared ownership (std feature required).
  • Rc Wrapper: Wrap a type into Rc<RefCell> for shared, mutable ownership (std feature required).
  • Arc Wrapper: Wrap a type into Arc for thread-safe reference-counted ownership (sync feature required).
  • Arc Wrapper: Wrap a type into Arc<Mutex> for shared, mutable, thread-safe ownership (sync feature required).

Installation

Add to your Cargo.toml:

[dependencies]
auto_wrap = "1.0.1"

Optional features:

[dependencies.auto_wrap]
version = "1.0.1"
features = ["sync", "std"]

Usage

use auto_wrap::WrapExt;

let x = 42u32.cell();
x.set(100);
assert_eq!(x.get(), 100);

#[cfg(feature = "std")]
let rc = 42u32.rc();

#[cfg(all(feature = "std", feature = "sync"))]
let arc_mutex = 0u32.arc_mutex();

Features Flags

std – Enable Rc, RefCell and related wrappers.

sync – Enable Arc and Mutex wrappers (requires std).

License

MIT