my_box 0.2.2

An educational, zero-dependency Rust implementation of a heap-allocated smart pointer (MyBox<T>), mirroring std::boxed::Box<T> for learning purposes.
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented7 out of 9 items with examples
  • Size
  • Source code size: 41.68 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 513.95 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ZenStarDev/MyBox
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ZenStarDev

MyBox

Documentation Crates.io

A zero-dependency, educational Rust library that reimplements Box<T> from first principles.

Quick Start

use my_box::MyBox;

let num = MyBox::new(42);
assert_eq!(*num, 42);

let s = MyBox::new(String::from("hello"));
println!("{}", *s);

Features

  • Single-ownership heap allocation — one owner, automatic cleanup via Drop
  • Zero-sized type (ZST) safeMyBox::new(()) works correctly
  • Recursive data structuresBox<List<T>> breaks infinite size cycles
  • Trait object supportBox<dyn Trait> for runtime polymorphism
  • Full trait forwardingClone, Deref, PartialEq, Hash, Display, and more
  • Fallible allocationtry_new returns Result instead of panicking on OOM
  • Consume to inner valueinto_inner extracts T from MyBox<T>

Installation

cargo add my-box

Documentation

Full API documentation is available at docs.rs/my-box.

License

  • Apache License, Version 2.0 (LICENSE)