Skip to content

Commit db6c712

Browse files
committed
Auto merge of rust-lang#28965 - bluss:ptr-write-doc, r=huonw
core: Update the safety docs for core::ptr::write Updated to reflect that not dropping a value is safe (but discouraged).
2 parents 9d3e79a + 4dee42f commit db6c712

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libcore/ptr.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ pub unsafe fn read_and_drop<T>(dest: *mut T) -> T {
145145
///
146146
/// # Safety
147147
///
148-
/// Beyond accepting a raw pointer, this operation is unsafe because it does
149-
/// not drop the contents of `dst`. This could leak allocations or resources,
150-
/// so care must be taken not to overwrite an object that should be dropped.
148+
/// This operation is marked unsafe because it accepts a raw pointer.
149+
///
150+
/// It does not drop the contents of `dst`. This is safe, but it could leak
151+
/// allocations or resources, so care must be taken not to overwrite an object
152+
/// that should be dropped.
151153
///
152154
/// This is appropriate for initializing uninitialized memory, or overwriting
153155
/// memory that has previously been `read` from.

0 commit comments

Comments
 (0)