@@ -194,9 +194,9 @@ use crate::vec::Vec;
194194/// ```
195195/// use std::mem;
196196///
197- /// let story = String::from("Once upon a time...");
197+ /// let mut story = String::from("Once upon a time...");
198198///
199- /// let ptr = story.as_ptr ();
199+ /// let ptr = story.as_mut_ptr ();
200200/// let len = story.len();
201201/// let capacity = story.capacity();
202202///
@@ -209,7 +209,7 @@ use crate::vec::Vec;
209209/// // We can re-build a String out of ptr, len, and capacity. This is all
210210/// // unsafe because we are responsible for making sure the components are
211211/// // valid:
212- /// let s = unsafe { String::from_raw_parts(ptr as *mut _ , len, capacity) } ;
212+ /// let s = unsafe { String::from_raw_parts(ptr, len, capacity) } ;
213213///
214214/// assert_eq!(String::from("Once upon a time..."), s);
215215/// ```
@@ -676,14 +676,14 @@ impl String {
676676 /// use std::mem;
677677 ///
678678 /// unsafe {
679- /// let s = String::from("hello");
680- /// let ptr = s.as_ptr ();
679+ /// let mut s = String::from("hello");
680+ /// let ptr = s.as_mut_ptr ();
681681 /// let len = s.len();
682682 /// let capacity = s.capacity();
683683 ///
684684 /// mem::forget(s);
685685 ///
686- /// let s = String::from_raw_parts(ptr as *mut _ , len, capacity);
686+ /// let s = String::from_raw_parts(ptr, len, capacity);
687687 ///
688688 /// assert_eq!(String::from("hello"), s);
689689 /// }
0 commit comments