Commit 8f9f3aa
authored
Rollup merge of rust-lang#89335 - mbrubeck:range-is-sorted, r=cuviper
Optimize is_sorted for Range and RangeInclusive
The [`Step`] trait guarantees that `Range<impl Step>` yields items in sorted order. We can override `Iterator::is_sorted` based on this guarantee, as we already do for `Iterator::min` and `max`.
Thank you to ``@fiveseven-lambda`` who pointed this out [on the Rust Users Forum](https://users.rust-lang.org/t/is-sorted-method-in-impl-iterator-for-range/64717).
[`Step`]: https://doc.rust-lang.org/stable/std/iter/trait.Step.html1 file changed
+10
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
675 | 680 | | |
676 | 681 | | |
677 | 682 | | |
| |||
1095 | 1100 | | |
1096 | 1101 | | |
1097 | 1102 | | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1098 | 1108 | | |
1099 | 1109 | | |
1100 | 1110 | | |
| |||
0 commit comments