|
16 | 16 | //!
|
17 | 17 | //! # Safety
|
18 | 18 | //!
|
19 |
| -//! Most functions in this module [dereference raw pointers]. |
20 |
| -//! |
21 |
| -//! In order for a pointer dereference to be safe, the pointer must be "valid". |
22 |
| -//! A valid pointer is one that satisfies **all** of the following conditions: |
| 19 | +//! Many functions in this module take raw pointers as arguments and dereference |
| 20 | +//! them. For this to be safe, these pointers must be valid. A valid pointer |
| 21 | +//! is one that satisfies **all** of the following conditions: |
23 | 22 | //!
|
24 | 23 | //! * The pointer is not null.
|
25 | 24 | //! * The pointer is not dangling (it does not point to memory which has been
|
26 | 25 | //! freed).
|
27 | 26 | //! * The pointer satisfies [LLVM's pointer aliasing rules].
|
28 | 27 | //!
|
29 |
| -//! [dereference raw pointers]: https://doc.rust-lang.org/book/second-edition/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer |
| 28 | +//! Valid pointers are not necessarily properly aligned. However, except for |
| 29 | +//! [`read_unaligned`] and [`write_unaligned`], most functions require their |
| 30 | +//! arguments to be aligned. Any alignment requirements will be explicitly |
| 31 | +//! stated in the function's documentation. |
| 32 | +//! |
30 | 33 | //! [LLVM's pointer aliasing rules]: https://llvm.org/docs/LangRef.html#pointer-aliasing-rules
|
| 34 | +//! [`read_unaligned`]: ./fn.read_unaligned.html |
| 35 | +//! [`write_unaligned`]: ./fn.write_unaligned.html |
31 | 36 |
|
32 | 37 | #![stable(feature = "rust1", since = "1.0.0")]
|
33 | 38 |
|
@@ -654,6 +659,7 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
|
654 | 659 | ///
|
655 | 660 | /// // Accessing unaligned values directly is safe.
|
656 | 661 | /// assert!(x.unaligned == v);
|
| 662 | +/// ``` |
657 | 663 | #[inline]
|
658 | 664 | #[stable(feature = "ptr_unaligned", since = "1.17.0")]
|
659 | 665 | pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
|
|
0 commit comments