diff options
| author | Ralf Jung <post@ralfj.de> | 2021-03-06 16:59:39 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2021-03-06 16:59:39 +0100 |
| commit | b75154897bd5a4f4e0678e1d0539db6f59f85ba1 (patch) | |
| tree | f114f295a55c269a1688a5e095cb104be82c3894 | |
| parent | 51748a8fc77283914d4135f31b5966a407208187 (diff) | |
| download | rust-b75154897bd5a4f4e0678e1d0539db6f59f85ba1.tar.gz rust-b75154897bd5a4f4e0678e1d0539db6f59f85ba1.zip | |
tweak MaybeUninit docs
| -rw-r--r-- | library/core/src/mem/maybe_uninit.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 26314213ff7..cb072931232 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -39,10 +39,11 @@ use crate::ptr; /// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️ /// ``` /// -/// Moreover, uninitialized memory is special in that the compiler knows that -/// it does not have a fixed value. This makes it undefined behavior to have -/// uninitialized data in a variable even if that variable has an integer type, -/// which otherwise can hold any *fixed* bit pattern: +/// Moreover, uninitialized memory is special in that it does not have a fixed value ("fixed" +/// meaning "it won't change without being written to"). Reading the same uninitialized byte +/// multiple times can give different results. This makes it undefined behavior to have +/// uninitialized data in a variable even if that variable has an integer type, which otherwise can +/// hold any *fixed* bit pattern: /// /// ```rust,no_run /// # #![allow(invalid_value)] |
