Fix failing doctests

This commit is contained in:
Dylan MacKenzie 2018-05-23 22:38:22 -07:00 committed by Ralf Jung
parent da58bebf01
commit 9f5a3cccb8
2 changed files with 4 additions and 4 deletions

View File

@ -1149,7 +1149,7 @@
/// Creating an invalid value:
///
/// ```no_run
/// use std::{mem, ptr};
/// use std::ptr;
///
/// let mut v = Box::new(0i32);
///

View File

@ -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");