Rust 1.99 (2024 edition) reference · 4 entries

Rust Traits and Smart Pointers

Derive standard traits, implement Display and From, and share data with Box, Rc, RefCell and Arc.

NameDescriptionSince
#[derive] Generate standard trait implementations such as Debug, Clone, PartialEq, Eq, Hash, Default and PartialOrd for your types.
impl Display Implement std::fmt::Display to control how a type prints with {} and converts with to_string().
From and Into Convert between types: implement From<T> and get Into for free; ? uses From to convert error types.
Box, Rc, RefCell and Arc Choose the right smart pointer: heap allocation, shared ownership, interior mutability, and thread-safe sharing.

Was this page helpful?