@@ -160,11 +160,10 @@ 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;
167- /// use std::ptr::addr_of_mut;
168167///
169168/// #[derive(Debug, PartialEq)]
170169/// pub struct Foo {
@@ -179,11 +178,11 @@ use crate::{fmt, intrinsics, ptr, slice};
179178/// // Initializing the `name` field
180179/// // Using `write` instead of assignment via `=` to not call `drop` on the
181180/// // old, uninitialized value.
182- /// unsafe { addr_of_mut!( (*ptr).name).write("Bob".to_string()); }
181+ /// unsafe { (&raw mut (*ptr).name).write("Bob".to_string()); }
183182///
184183/// // Initializing the `list` field
185184/// // 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]); }
185+ /// unsafe { (&raw mut (*ptr).list).write(vec![0, 1, 2]); }
187186///
188187/// // All the fields are initialized, so we call `assume_init` to get an initialized Foo.
189188/// unsafe { uninit.assume_init() }
@@ -197,7 +196,7 @@ use crate::{fmt, intrinsics, ptr, slice};
197196/// }
198197/// );
199198/// ```
200- /// [`std::ptr::addr_of_mut `]: crate::ptr::addr_of_mut
199+ /// [`&raw `]: https://doc.rust-lang.org/reference/types/pointer.html#r-type.pointer.raw.constructor
201200/// [ub]: ../../reference/behavior-considered-undefined.html
202201///
203202/// # Layout
0 commit comments