fix doctest
This commit is contained in:
parent
789b4d1a4f
commit
aaafc3c7fa
@ -1042,7 +1042,7 @@ fn deref_mut(&mut self) -> &mut T {
|
|||||||
/// even in unsafe code. As a consequence, 0-initializing a variable of reference
|
/// even in unsafe code. As a consequence, 0-initializing a variable of reference
|
||||||
/// type causes instantaneous undefined behavior, no matter whether that reference
|
/// type causes instantaneous undefined behavior, no matter whether that reference
|
||||||
/// ever gets used to access memory:
|
/// ever gets used to access memory:
|
||||||
/// ```rust,ignore
|
/// ```rust,no_run
|
||||||
/// use std::mem;
|
/// use std::mem;
|
||||||
///
|
///
|
||||||
/// let x: &i32 = mem::zeroed(); // undefined behavior!
|
/// let x: &i32 = mem::zeroed(); // undefined behavior!
|
||||||
@ -1065,7 +1065,7 @@ fn deref_mut(&mut self) -> &mut T {
|
|||||||
/// // Set it to a valid value.
|
/// // Set it to a valid value.
|
||||||
/// x.set(&0);
|
/// x.set(&0);
|
||||||
/// // Extract the initialized data -- this is only allowed *after* properly
|
/// // Extract the initialized data -- this is only allowed *after* properly
|
||||||
/// initializing `x`!
|
/// // initializing `x`!
|
||||||
/// let x = unsafe { x.into_initialized() };
|
/// let x = unsafe { x.into_initialized() };
|
||||||
/// ```
|
/// ```
|
||||||
/// The compiler then knows to not optimize this code.
|
/// The compiler then knows to not optimize this code.
|
||||||
|
Loading…
Reference in New Issue
Block a user