Skip to content

Commit 3e0f472

Browse files
committed
Add more doc tests
1 parent e84c808 commit 3e0f472

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

library/core/src/iter/traits/iterator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4041,6 +4041,12 @@ pub trait Iterator {
40414041
///
40424042
/// assert!([1, 2, 2, 9].iter().is_sorted_by(|a, b| a <= b));
40434043
/// assert!(![1, 2, 2, 9].iter().is_sorted_by(|a, b| a < b));
4044+
///
4045+
/// assert!([0].iter().is_sorted_by(|a, b| true));
4046+
/// assert!([0].iter().is_sorted_by(|a, b| false));
4047+
///
4048+
/// assert!(std::iter::empty::<i32>().is_sorted_by(|a, b| false));
4049+
/// assert!(std::iter::empty::<i32>().is_sorted_by(|a, b| true));
40444050
/// ```
40454051
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
40464052
#[rustc_do_not_const_check]

library/core/src/slice/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4118,6 +4118,13 @@ impl<T> [T] {
41184118
///
41194119
/// assert!([1, 2, 2, 9].is_sorted_by(|a, b| a <= b));
41204120
/// assert!(![1, 2, 2, 9].is_sorted_by(|a, b| a < b));
4121+
///
4122+
/// assert!([0].is_sorted_by(|a, b| true));
4123+
/// assert!([0].is_sorted_by(|a, b| false));
4124+
///
4125+
/// let empty: [i32; 0] = [];
4126+
/// assert!(empty.is_sorted_by(|a, b| false));
4127+
/// assert!(empty.is_sorted_by(|a, b| true));
41214128
/// ```
41224129
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
41234130
#[must_use]

0 commit comments

Comments
 (0)