Rollup merge of #33056 - GuillaumeGomez:as_mut_ptr_example, r=steveklabnik

Improve as_mut ptr method example

r? @steveklabnik
This commit is contained in:
Steve Klabnik 2016-04-28 09:51:43 -04:00
commit 385a54f4d4

View file

@ -459,6 +459,9 @@ impl<T: ?Sized> *mut T {
/// ```
/// let mut s = [1, 2, 3];
/// let ptr: *mut u32 = s.as_mut_ptr();
/// let first_value = unsafe { ptr.as_mut().unwrap() };
/// *first_value = 4;
/// println!("{:?}", s); // It'll print: "[4, 2, 3]".
/// ```
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
#[inline]