@@ -1407,9 +1407,8 @@ pub const unsafe fn read<T>(src: *const T) -> T {
1407
1407
/// As a result, using `&packed.unaligned as *const FieldType` causes immediate
1408
1408
/// *undefined behavior* in your program.
1409
1409
///
1410
- /// Instead you must use the [`ptr::addr_of!`](addr_of) macro to
1411
- /// create the pointer. You may use that returned pointer together with this
1412
- /// function.
1410
+ /// Instead you must use the `&raw const` syntax to create the pointer.
1411
+ /// You may use that constructed pointer together with this function.
1413
1412
///
1414
1413
/// An example of what not to do and how this relates to `read_unaligned` is:
1415
1414
///
@@ -1427,7 +1426,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
1427
1426
///
1428
1427
/// // Take the address of a 32-bit integer which is not aligned.
1429
1428
/// // In contrast to `&packed.unaligned as *const _`, this has no undefined behavior.
1430
- /// let unaligned = std::ptr::addr_of!( packed.unaligned) ;
1429
+ /// let unaligned = &raw const packed.unaligned;
1431
1430
///
1432
1431
/// let v = unsafe { std::ptr::read_unaligned(unaligned) };
1433
1432
/// assert_eq!(v, 0x01020304);
@@ -1615,9 +1614,8 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
1615
1614
/// As a result, using `&packed.unaligned as *const FieldType` causes immediate
1616
1615
/// *undefined behavior* in your program.
1617
1616
///
1618
- /// Instead, you must use the [`ptr::addr_of_mut!`](addr_of_mut)
1619
- /// macro to create the pointer. You may use that returned pointer together with
1620
- /// this function.
1617
+ /// Instead, you must use the `&raw mut` syntax to create the pointer.
1618
+ /// You may use that constructed pointer together with this function.
1621
1619
///
1622
1620
/// An example of how to do it and how this relates to `write_unaligned` is:
1623
1621
///
@@ -1632,7 +1630,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
1632
1630
///
1633
1631
/// // Take the address of a 32-bit integer which is not aligned.
1634
1632
/// // In contrast to `&packed.unaligned as *mut _`, this has no undefined behavior.
1635
- /// let unaligned = std::ptr::addr_of_mut!( packed.unaligned) ;
1633
+ /// let unaligned = &raw mut packed.unaligned;
1636
1634
///
1637
1635
/// unsafe { std::ptr::write_unaligned(unaligned, 42) };
1638
1636
///
0 commit comments