File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1149,7 +1149,7 @@ extern "rust-intrinsic" {
1149
1149
/// Creating an invalid value:
1150
1150
///
1151
1151
/// ```no_run
1152
- /// use std::{mem, ptr} ;
1152
+ /// use std::ptr;
1153
1153
///
1154
1154
/// let mut v = Box::new(0i32);
1155
1155
///
Original file line number Diff line number Diff line change @@ -396,7 +396,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
396
396
/// ```
397
397
/// use std::ptr;
398
398
///
399
- /// let mut s = String::new ("foo");
399
+ /// let mut s = String::from ("foo");
400
400
/// unsafe {
401
401
/// // `s2` now points to the same underlying memory as `s1`.
402
402
/// let mut s2 = ptr::read(&s);
@@ -410,10 +410,10 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
410
410
///
411
411
/// // Assigning to `s` would cause the old value to be dropped again,
412
412
/// // resulting in undefined behavior.
413
- /// // s = String::new ("bar"); // ERROR
413
+ /// // s = String::from ("bar"); // ERROR
414
414
///
415
415
/// // `ptr::write` can be used to overwrite a value without dropping it.
416
- /// ptr::write(&s, String::new ("bar"));
416
+ /// ptr::write(&mut s, String::from ("bar"));
417
417
/// }
418
418
///
419
419
/// assert_eq!(s, "bar");
You can’t perform that action at this time.
0 commit comments