diff options
| author | Kornel <kornel@geekhood.net> | 2024-12-20 17:02:46 +0000 |
|---|---|---|
| committer | Kornel <kornel@geekhood.net> | 2024-12-21 01:26:47 +0000 |
| commit | 7b42bc0c7935e9f5fefd017249041d64f27bb583 (patch) | |
| tree | 5b65fd21829609d725f852c11e141aa59573e349 /library/core/src/ptr | |
| parent | 5f23ef7d3f7a8c3e0ca5c4e1978829c0448a3686 (diff) | |
Less unwrap() in documentation
Diffstat (limited to 'library/core/src/ptr')
| -rw-r--r-- | library/core/src/ptr/const_ptr.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index f100adecbbb..ac905eceaa8 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -502,11 +502,12 @@ impl<T: ?Sized> *const T { /// let mut out = String::new(); /// while ptr != end_rounded_up { /// unsafe { - /// write!(&mut out, "{}, ", *ptr).unwrap(); + /// write!(&mut out, "{}, ", *ptr)?; /// } /// ptr = ptr.wrapping_offset(step); /// } /// assert_eq!(out.as_str(), "1, 3, 5, "); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "ptr_wrapping_offset", since = "1.16.0")] #[must_use = "returns a new pointer rather than modifying its argument"] @@ -1125,11 +1126,12 @@ impl<T: ?Sized> *const T { /// let mut out = String::new(); /// while ptr != end_rounded_up { /// unsafe { - /// write!(&mut out, "{}, ", *ptr).unwrap(); + /// write!(&mut out, "{}, ", *ptr)?; /// } /// ptr = ptr.wrapping_add(step); /// } /// assert_eq!(out, "1, 3, 5, "); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] @@ -1203,11 +1205,12 @@ impl<T: ?Sized> *const T { /// let mut out = String::new(); /// while ptr != start_rounded_down { /// unsafe { - /// write!(&mut out, "{}, ", *ptr).unwrap(); + /// write!(&mut out, "{}, ", *ptr)?; /// } /// ptr = ptr.wrapping_sub(step); /// } /// assert_eq!(out, "5, 3, 1, "); + /// # std::fmt::Result::Ok(()) /// ``` #[stable(feature = "pointer_methods", since = "1.26.0")] #[must_use = "returns a new pointer rather than modifying its argument"] |
