Skip to content

Commit ac47cd1

Browse files
committed
docs: clarify explicitly freeing heap allocated memory
1 parent f1b104f commit ac47cd1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/alloc/src/boxed.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,12 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
10441044
/// dealloc(p as *mut u8, Layout::new::<String>());
10451045
/// }
10461046
/// ```
1047-
///
1047+
/// Note: This is equivalent to the following:
1048+
/// ```
1049+
/// let x = Box::new(String::from("Hello"));
1050+
/// let p = Box::into_raw(x);
1051+
/// drop(Box::from_raw(ptr));
1052+
/// ```
10481053
/// [memory layout]: self#memory-layout
10491054
#[stable(feature = "box_raw", since = "1.4.0")]
10501055
#[inline]

0 commit comments

Comments
 (0)