Fix failing doctests
This commit is contained in:
parent
da58bebf01
commit
9f5a3cccb8
@ -1149,7 +1149,7 @@
|
||||
/// Creating an invalid value:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::{mem, ptr};
|
||||
/// use std::ptr;
|
||||
///
|
||||
/// let mut v = Box::new(0i32);
|
||||
///
|
||||
|
@ -396,7 +396,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
|
||||
/// ```
|
||||
/// use std::ptr;
|
||||
///
|
||||
/// let mut s = String::new("foo");
|
||||
/// let mut s = String::from("foo");
|
||||
/// unsafe {
|
||||
/// // `s2` now points to the same underlying memory as `s1`.
|
||||
/// let mut s2 = ptr::read(&s);
|
||||
@ -410,10 +410,10 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
|
||||
///
|
||||
/// // Assigning to `s` would cause the old value to be dropped again,
|
||||
/// // resulting in undefined behavior.
|
||||
/// // s = String::new("bar"); // ERROR
|
||||
/// // s = String::from("bar"); // ERROR
|
||||
///
|
||||
/// // `ptr::write` can be used to overwrite a value without dropping it.
|
||||
/// ptr::write(&s, String::new("bar"));
|
||||
/// ptr::write(&mut s, String::from("bar"));
|
||||
/// }
|
||||
///
|
||||
/// assert_eq!(s, "bar");
|
||||
|
Loading…
Reference in New Issue
Block a user