Skip to main content

One doc tagged with "deref-coercion"

View all tags

Deref Trait for Treating Smart Pointers like Regular References

After learning how to allocate data on the heap with Box, we'll now explore the magic that makes smart pointers so convenient. The Deref trait is the key to this convenience, as it allows a smart pointer struct to be treated like a regular reference. This enables you to write code that works with both references and smart pointers seamlessly.