about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorJake Goulding <jake.goulding@gmail.com>2019-10-22 13:54:09 -0400
committerJake Goulding <jake.goulding@gmail.com>2019-10-25 11:20:47 -0400
commit0d21d257c9691983fd51e7d5d9ace4de8933114c (patch)
treef5006723ba89dfbcb40364617cd79f0df25f9aac /src/liballoc/string.rs
parent23f890f10202a71168c6424da0cdf94135d3c40c (diff)
downloadrust-0d21d257c9691983fd51e7d5d9ace4de8933114c.tar.gz
rust-0d21d257c9691983fd51e7d5d9ace4de8933114c.zip
Remove unneeded pointer casting
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 639124e26cc..108c91fba1f 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -194,9 +194,9 @@ use crate::vec::Vec;
 /// ```
 /// use std::mem;
 ///
-/// let story = String::from("Once upon a time...");
+/// let mut story = String::from("Once upon a time...");
 ///
-/// let ptr = story.as_ptr();
+/// let ptr = story.as_mut_ptr();
 /// let len = story.len();
 /// let capacity = story.capacity();
 ///
@@ -209,7 +209,7 @@ use crate::vec::Vec;
 /// // We can re-build a String out of ptr, len, and capacity. This is all
 /// // unsafe because we are responsible for making sure the components are
 /// // valid:
-/// let s = unsafe { String::from_raw_parts(ptr as *mut _, len, capacity) } ;
+/// let s = unsafe { String::from_raw_parts(ptr, len, capacity) } ;
 ///
 /// assert_eq!(String::from("Once upon a time..."), s);
 /// ```
@@ -676,14 +676,14 @@ impl String {
     /// use std::mem;
     ///
     /// unsafe {
-    ///     let s = String::from("hello");
-    ///     let ptr = s.as_ptr();
+    ///     let mut s = String::from("hello");
+    ///     let ptr = s.as_mut_ptr();
     ///     let len = s.len();
     ///     let capacity = s.capacity();
     ///
     ///     mem::forget(s);
     ///
-    ///     let s = String::from_raw_parts(ptr as *mut _, len, capacity);
+    ///     let s = String::from_raw_parts(ptr, len, capacity);
     ///
     ///     assert_eq!(String::from("hello"), s);
     /// }