Skip to content

Commit eecae1d

Browse files
Fix failing doctests
1 parent ac53367 commit eecae1d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/libcore/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ extern "rust-intrinsic" {
11491149
/// Creating an invalid value:
11501150
///
11511151
/// ```no_run
1152-
/// use std::{mem, ptr};
1152+
/// use std::ptr;
11531153
///
11541154
/// let mut v = Box::new(0i32);
11551155
///

src/libcore/ptr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
383383
/// ```
384384
/// use std::ptr;
385385
///
386-
/// let mut s = String::new("foo");
386+
/// let mut s = String::from("foo");
387387
/// unsafe {
388388
/// // `s2` now points to the same underlying memory as `s1`.
389389
/// let mut s2 = ptr::read(&s);
@@ -397,10 +397,10 @@ pub unsafe fn replace<T>(dest: *mut T, mut src: T) -> T {
397397
///
398398
/// // Assigning to `s` would cause the old value to be dropped again,
399399
/// // resulting in undefined behavior.
400-
/// // s = String::new("bar"); // ERROR
400+
/// // s = String::from("bar"); // ERROR
401401
///
402402
/// // `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"));
404404
/// }
405405
///
406406
/// assert_eq!(s, "bar");

0 commit comments

Comments
 (0)