Skip to content

Commit 29a444b

Browse files
committed
replace addr_of_mut with &raw mut in maybeuninit docs
1 parent f520900 commit 29a444b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ use crate::{fmt, intrinsics, ptr, slice};
160160
///
161161
/// ## Initializing a struct field-by-field
162162
///
163-
/// You can use `MaybeUninit<T>`, and the [`std::ptr::addr_of_mut`] macro, to initialize structs field by field:
163+
/// You can use `MaybeUninit<T>`, and the [`&raw`] syntax, to initialize structs field by field:
164164
///
165165
/// ```rust
166166
/// use std::mem::MaybeUninit;
@@ -179,11 +179,11 @@ use crate::{fmt, intrinsics, ptr, slice};
179179
/// // Initializing the `name` field
180180
/// // Using `write` instead of assignment via `=` to not call `drop` on the
181181
/// // old, uninitialized value.
182-
/// unsafe { addr_of_mut!((*ptr).name).write("Bob".to_string()); }
182+
/// unsafe { (&raw mut (*ptr).name).write("Bob".to_string()); }
183183
///
184184
/// // Initializing the `list` field
185185
/// // If there is a panic here, then the `String` in the `name` field leaks.
186-
/// unsafe { addr_of_mut!((*ptr).list).write(vec![0, 1, 2]); }
186+
/// unsafe { (&raw mut (*ptr).list).write(vec![0, 1, 2]); }
187187
///
188188
/// // All the fields are initialized, so we call `assume_init` to get an initialized Foo.
189189
/// unsafe { uninit.assume_init() }
@@ -197,7 +197,7 @@ use crate::{fmt, intrinsics, ptr, slice};
197197
/// }
198198
/// );
199199
/// ```
200-
/// [`std::ptr::addr_of_mut`]: crate::ptr::addr_of_mut
200+
/// [`&raw`]: https://doc.rust-lang.org/reference/types/pointer.html#r-type.pointer.raw.constructor
201201
/// [ub]: ../../reference/behavior-considered-undefined.html
202202
///
203203
/// # Layout

0 commit comments

Comments
 (0)