File tree 2 files changed +4
-4
lines changed
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 @@ -383,7 +383,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
383
383
/// ```
384
384
/// use std::ptr;
385
385
///
386
- /// let mut s = String::new ("foo");
386
+ /// let mut s = String::from ("foo");
387
387
/// unsafe {
388
388
/// // `s2` now points to the same underlying memory as `s1`.
389
389
/// let mut s2 = ptr::read(&s);
@@ -397,10 +397,10 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
397
397
///
398
398
/// // Assigning to `s` would cause the old value to be dropped again,
399
399
/// // resulting in undefined behavior.
400
- /// // s = String::new ("bar"); // ERROR
400
+ /// // s = String::from ("bar"); // ERROR
401
401
///
402
402
/// // `ptr::write` can be used to overwrite a value without dropping it.
403
- /// ptr::write(&s, String::new ("bar"));
403
+ /// ptr::write(&mut s, String::from ("bar"));
404
404
/// }
405
405
///
406
406
/// assert_eq!(s, "bar");
You can’t perform that action at this time.
0 commit comments