diff options
| author | Connor Tsui <connor.tsui20@gmail.com> | 2025-08-30 11:15:41 +0100 |
|---|---|---|
| committer | Connor Tsui <connor.tsui20@gmail.com> | 2025-08-30 11:26:26 +0100 |
| commit | 114c0c2fefbc90d1cb71f6a0c4d150174e73ca75 (patch) | |
| tree | 395e925111236608d26196d6552b2ed9be44412d | |
| parent | 9c1255f0a46e7a8d22f17ad5705f0c8e2018bfe6 (diff) | |
| download | rust-114c0c2fefbc90d1cb71f6a0c4d150174e73ca75.tar.gz rust-114c0c2fefbc90d1cb71f6a0c4d150174e73ca75.zip | |
Add `#[must_use] and update `cloned` documentation
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com> Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
| -rw-r--r-- | library/core/src/ops/range.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index b1df5afa202..c0a27775694 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -751,6 +751,7 @@ impl<T: Copy> Bound<&T> { /// assert_eq!((1..12).start_bound().copied(), Included(1)); /// ``` #[unstable(feature = "bound_copied", issue = "145966")] + #[must_use] pub fn copied(self) -> Bound<T> { match self { Bound::Unbounded => Bound::Unbounded, @@ -769,8 +770,11 @@ impl<T: Clone> Bound<&T> { /// use std::ops::Bound::*; /// use std::ops::RangeBounds; /// - /// assert_eq!((1..12).start_bound(), Included(&1)); - /// assert_eq!((1..12).start_bound().cloned(), Included(1)); + /// let a1 = String::from("a"); + /// let (a2, a3, a4) = (a1.clone(), a1.clone(), a1.clone()); + /// + /// assert_eq!(Included(&a1), (a2..).start_bound()); + /// assert_eq!(Included(a3), (a4..).start_bound().cloned()); /// ``` #[must_use = "`self` will be dropped if the result is not used"] #[stable(feature = "bound_cloned", since = "1.55.0")] |
