@@ -194,9 +194,9 @@ use crate::vec::Vec;
194
194
/// ```
195
195
/// use std::mem;
196
196
///
197
- /// let story = String::from("Once upon a time...");
197
+ /// let mut story = String::from("Once upon a time...");
198
198
///
199
- /// let ptr = story.as_ptr ();
199
+ /// let ptr = story.as_mut_ptr ();
200
200
/// let len = story.len();
201
201
/// let capacity = story.capacity();
202
202
///
@@ -209,7 +209,7 @@ use crate::vec::Vec;
209
209
/// // We can re-build a String out of ptr, len, and capacity. This is all
210
210
/// // unsafe because we are responsible for making sure the components are
211
211
/// // 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) } ;
213
213
///
214
214
/// assert_eq!(String::from("Once upon a time..."), s);
215
215
/// ```
@@ -676,14 +676,14 @@ impl String {
676
676
/// use std::mem;
677
677
///
678
678
/// 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 ();
681
681
/// let len = s.len();
682
682
/// let capacity = s.capacity();
683
683
///
684
684
/// mem::forget(s);
685
685
///
686
- /// let s = String::from_raw_parts(ptr as *mut _ , len, capacity);
686
+ /// let s = String::from_raw_parts(ptr, len, capacity);
687
687
///
688
688
/// assert_eq!(String::from("hello"), s);
689
689
/// }
0 commit comments