Skip to content
masterclass Buddy

Rust · Class

Box

Box<T> uniquely owns a heap allocation containing T. Create one with Box::new, access its value with *, and let scope-based ownership release it.

Last updated

Since
1.0.0

Syntax

pub struct Box<T, A = Global>(/* private fields */)

pub fn new(x: T) -> Box<T>

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Box::new
  • Box::downcast
  • Box::into_boxed_slice
  • Box::into_pin
  • MaybeUninit
  • Any

Source: Box in std::boxed - Rust. Checked 2026-11-03.