about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-04-14 23:24:34 +0200
committerGitHub <noreply@github.com>2024-04-14 23:24:34 +0200
commit32be7b712989cd3da0f056ca04b3020e2c7276e9 (patch)
treea3535a775490a9bad07dc1b37abe8e65fc772300
parent4d32bc3801fb66d359ebcc8e0e90733094602858 (diff)
parent5b8864ab80bfc4d9a4c8b41347a0ad4bf99a8681 (diff)
downloadrust-32be7b712989cd3da0f056ca04b3020e2c7276e9.tar.gz
rust-32be7b712989cd3da0f056ca04b3020e2c7276e9.zip
Rollup merge of #123915 - shenawy29:patch-1, r=Nilstrieb
improve documentation slightly regarding some pointer methods
-rw-r--r--library/core/src/ptr/mut_ptr.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index 08f03af355d..d8f91f1996b 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -464,8 +464,8 @@ impl<T: ?Sized> *mut T {
     /// let ptr: *mut u32 = s.as_mut_ptr();
     ///
     /// unsafe {
-    ///     println!("{}", *ptr.offset(1));
-    ///     println!("{}", *ptr.offset(2));
+    ///     assert_eq!(2, *ptr.offset(1));
+    ///     assert_eq!(3, *ptr.offset(2));
     /// }
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -1027,8 +1027,8 @@ impl<T: ?Sized> *mut T {
     /// let ptr: *const u8 = s.as_ptr();
     ///
     /// unsafe {
-    ///     println!("{}", *ptr.add(1) as char);
-    ///     println!("{}", *ptr.add(2) as char);
+    ///     assert_eq!('2', *ptr.add(1) as char);
+    ///     assert_eq!('3', *ptr.add(2) as char);
     /// }
     /// ```
     #[stable(feature = "pointer_methods", since = "1.26.0")]
@@ -1111,8 +1111,8 @@ impl<T: ?Sized> *mut T {
     ///
     /// unsafe {
     ///     let end: *const u8 = s.as_ptr().add(3);
-    ///     println!("{}", *end.sub(1) as char);
-    ///     println!("{}", *end.sub(2) as char);
+    ///     assert_eq!('3', *end.sub(1) as char);
+    ///     assert_eq!('2', *end.sub(2) as char);
     /// }
     /// ```
     #[stable(feature = "pointer_methods", since = "1.26.0")]