about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-04-17 18:50:49 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-04-17 18:50:49 +0200
commit4d0b0e975b30d067e2347b74ea19f49c7f04fbda (patch)
tree5cf243b932151b18b41fe1451c1e21ce088741fc
parenta6264002637f60322d17329eaf4a25b9abe2c638 (diff)
downloadrust-4d0b0e975b30d067e2347b74ea19f49c7f04fbda.tar.gz
rust-4d0b0e975b30d067e2347b74ea19f49c7f04fbda.zip
Improve as_mut ptr method example
-rw-r--r--src/libcore/ptr.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index a3c7ab481a7..8b3a14b24df 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -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]