Skip to content

Commit 43abc8e

Browse files
authored
Rollup merge of rust-lang#76088 - hbina:add_example, r=LukasKalbertodt
Add more examples to lexicographic cmp on Iterators. Given two arrays of T1 and T2, the most important rule of lexicographical comparison is that two arrays of equal length will be compared until the first difference occured. The examples provided only focuses on the second rule that says that the shorter array will be filled with some T2 that is less than every T1. Which is only possible because of the first rule.
2 parents d3f5148 + 3883698 commit 43abc8e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/iter/traits/iterator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,6 +3078,7 @@ pub trait Iterator {
30783078
/// assert_eq!([1].iter().lt([1].iter()), false);
30793079
/// assert_eq!([1].iter().lt([1, 2].iter()), true);
30803080
/// assert_eq!([1, 2].iter().lt([1].iter()), false);
3081+
/// assert_eq!([1, 2].iter().lt([1, 2].iter()), false);
30813082
/// ```
30823083
#[stable(feature = "iter_order", since = "1.5.0")]
30833084
fn lt<I>(self, other: I) -> bool
@@ -3098,6 +3099,7 @@ pub trait Iterator {
30983099
/// assert_eq!([1].iter().le([1].iter()), true);
30993100
/// assert_eq!([1].iter().le([1, 2].iter()), true);
31003101
/// assert_eq!([1, 2].iter().le([1].iter()), false);
3102+
/// assert_eq!([1, 2].iter().le([1, 2].iter()), true);
31013103
/// ```
31023104
#[stable(feature = "iter_order", since = "1.5.0")]
31033105
fn le<I>(self, other: I) -> bool
@@ -3118,6 +3120,7 @@ pub trait Iterator {
31183120
/// assert_eq!([1].iter().gt([1].iter()), false);
31193121
/// assert_eq!([1].iter().gt([1, 2].iter()), false);
31203122
/// assert_eq!([1, 2].iter().gt([1].iter()), true);
3123+
/// assert_eq!([1, 2].iter().gt([1, 2].iter()), false);
31213124
/// ```
31223125
#[stable(feature = "iter_order", since = "1.5.0")]
31233126
fn gt<I>(self, other: I) -> bool
@@ -3138,6 +3141,7 @@ pub trait Iterator {
31383141
/// assert_eq!([1].iter().ge([1].iter()), true);
31393142
/// assert_eq!([1].iter().ge([1, 2].iter()), false);
31403143
/// assert_eq!([1, 2].iter().ge([1].iter()), true);
3144+
/// assert_eq!([1, 2].iter().ge([1, 2].iter()), true);
31413145
/// ```
31423146
#[stable(feature = "iter_order", since = "1.5.0")]
31433147
fn ge<I>(self, other: I) -> bool

0 commit comments

Comments
 (0)