1.4.0

After calling this function, the raw pointer is owned by the
resulting Box. Specifically, the Box destructor will call
the destructor of T and free the allocated memory. Since the
way Box allocates and releases memory is unspecified, the
only valid pointer to pass to this function is the one taken
from another Box via the Box::into_raw function.

This function is unsafe because improper use may lead to
memory problems. For example, a double-free may occur if the
function is called twice on the same raw pointer.

1.4.0

After calling this function, the caller is responsible for the
memory previously managed by the Box. In particular, the
caller should properly destroy T and release the memory. The
proper way to do so is to convert the raw pointer back into a
Box with the Box::from_raw function.

Note: this is an associated function, which means that you have
to call it as Box::into_raw(b) instead of b.into_raw(). This
is so that there is no conflict with a method on the inner type.

🔬 This is a nightly-only experimental API. (box_into_raw_non_null #47336)

Consumes the Box, returning the wrapped pointer as NonNull<T>.

After calling this function, the caller is responsible for the
memory previously managed by the Box. In particular, the
caller should properly destroy T and release the memory. The
proper way to do so is to convert the NonNull<T> pointer
into a raw pointer and back into a Box with the Box::from_raw
function.

Note: this is an associated function, which means that you have
to call it as Box::into_raw_non_null(b)
instead of b.into_raw_non_null(). This
is so that there is no conflict with a method on the inner type.

1.26.0

Consumes and leaks the Box, returning a mutable reference,
&'a mut T. Note that the type T must outlive the chosen lifetime
'a. If the type has only static references, or none at all, then this
may be chosen to be 'static.

This function is mainly useful for data that lives for the remainder of
the program's life. Dropping the returned reference will cause a memory
leak. If this is not acceptable, the reference should first be wrapped
with the Box::from_raw function producing a Box. This Box can
then be dropped which will properly destroy T and release the
allocated memory.

Note: this is an associated function, which means that you have
to call it as Box::leak(b) instead of b.leak(). This
is so that there is no conflict with a method on the inner type.