Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 114c0c2

Browse files
connortsui20joboet
andcommitted
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>
1 parent 9c1255f commit 114c0c2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎library/core/src/ops/range.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ impl<T: Copy> Bound<&T> {
751751
/// assert_eq!((1..12).start_bound().copied(), Included(1));
752752
/// ```
753753
#[unstable(feature = "bound_copied", issue = "145966")]
754+
#[must_use]
754755
pub fn copied(self) -> Bound<T> {
755756
match self {
756757
Bound::Unbounded => Bound::Unbounded,
@@ -769,8 +770,11 @@ impl<T: Clone> Bound<&T> {
769770
/// use std::ops::Bound::*;
770771
/// use std::ops::RangeBounds;
771772
///
772-
/// assert_eq!((1..12).start_bound(), Included(&1));
773-
/// assert_eq!((1..12).start_bound().cloned(), Included(1));
773+
/// let a1 = String::from("a");
774+
/// let (a2, a3, a4) = (a1.clone(), a1.clone(), a1.clone());
775+
///
776+
/// assert_eq!(Included(&a1), (a2..).start_bound());
777+
/// assert_eq!(Included(a3), (a4..).start_bound().cloned());
774778
/// ```
775779
#[must_use = "`self` will be dropped if the result is not used"]
776780
#[stable(feature = "bound_cloned", since = "1.55.0")]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /