Skip to content

Commit 8e49a4c

Browse files
committed
Add example clamping by length
1 parent ae62b1b commit 8e49a4c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/cmp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,8 @@ pub const trait Ord: [const] Eq + [const] PartialOrd<Self> + PointeeSized {
11091109
/// #![feature(clamp_min_max)]
11101110
/// assert_eq!(12.clamp_max(10), 10);
11111111
/// assert_eq!(4.clamp_max(7), 4);
1112+
/// let s = "hello";
1113+
/// assert_eq!(&s[..32.clamp_max(s.len())], s);
11121114
/// ```
11131115
#[must_use]
11141116
#[inline]

0 commit comments

Comments
 (0)