Skip to content

Commit 8ab12d7

Browse files
authored
Rollup merge of rust-lang#40387 - tbu-:pr_doc_ptr_write2, r=steveklabnik
Reword the non-dropping of `src` for `ptr::write{,_unaligned}` @niconii Is it OK if I put your wording into the documentation? CC @nagisa
2 parents 11a3376 + 13341f4 commit 8ab12d7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libcore/ptr.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@ pub unsafe fn read_unaligned<T>(src: *const T) -> T {
191191
/// allocations or resources, so care must be taken not to overwrite an object
192192
/// that should be dropped.
193193
///
194-
/// It does not immediately drop the contents of `src` either; it is rather
195-
/// *moved* into the memory location `dst` and will be dropped whenever that
196-
/// location goes out of scope.
194+
/// Additionally, it does not drop `src`. Semantically, `src` is moved into the
195+
/// location pointed to by `dst`.
197196
///
198197
/// This is appropriate for initializing uninitialized memory, or overwriting
199198
/// memory that has previously been `read` from.
@@ -233,6 +232,9 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
233232
/// allocations or resources, so care must be taken not to overwrite an object
234233
/// that should be dropped.
235234
///
235+
/// Additionally, it does not drop `src`. Semantically, `src` is moved into the
236+
/// location pointed to by `dst`.
237+
///
236238
/// This is appropriate for initializing uninitialized memory, or overwriting
237239
/// memory that has previously been `read` from.
238240
///

0 commit comments

Comments
 (0)