Skip to content

Commit e45701f

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

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/alloc/src/boxed.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,12 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
10441044
/// dealloc(p as *mut u8, Layout::new::<String>());
10451045
/// }
10461046
/// ```
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+
/// ```
10471053
///
10481054
/// [memory layout]: self#memory-layout
10491055
#[stable(feature = "box_raw", since = "1.4.0")]

0 commit comments

Comments
 (0)