forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#55045 - kleimkuhler:add-std-is_sorted, r=KodrAus
Add `is_sorted` to `Iterator` and `[T]` This is an initial implementation for the first step of [RFC 2351](https://github.com/rust-lang/rfcs/blob/master/text/2351-is-sorted.md) Tracking issue: rust-lang#53485
- Loading branch information
Showing
9 changed files
with
271 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# `is_sorted` | ||
|
||
The tracking issue for this feature is: [#53485] | ||
|
||
[#53485]: https://github.com/rust-lang/rust/issues/53485 | ||
|
||
------------------------ | ||
|
||
Add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to `[T]`; | ||
add the methods `is_sorted`, `is_sorted_by` and `is_sorted_by_key` to | ||
`Iterator`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
fn main() { | ||
// Assert `Iterator` methods are feature gated | ||
assert!([1, 2, 2, 9].iter().is_sorted()); | ||
//~^ ERROR: use of unstable library feature 'is_sorted': new API | ||
assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs())); | ||
//~^ ERROR: use of unstable library feature 'is_sorted': new API | ||
|
||
// Assert `[T]` methods are feature gated | ||
assert!([1, 2, 2, 9].is_sorted()); | ||
//~^ ERROR: use of unstable library feature 'is_sorted': new API | ||
assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs())); | ||
//~^ ERROR: use of unstable library feature 'is_sorted': new API | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error[E0658]: use of unstable library feature 'is_sorted': new API (see issue #53485) | ||
--> $DIR/feature-gate-is_sorted.rs:3:33 | ||
| | ||
LL | assert!([1, 2, 2, 9].iter().is_sorted()); | ||
| ^^^^^^^^^ | ||
| | ||
= help: add #![feature(is_sorted)] to the crate attributes to enable | ||
|
||
error[E0658]: use of unstable library feature 'is_sorted': new API (see issue #53485) | ||
--> $DIR/feature-gate-is_sorted.rs:5:39 | ||
| | ||
LL | assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs())); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= help: add #![feature(is_sorted)] to the crate attributes to enable | ||
|
||
error[E0658]: use of unstable library feature 'is_sorted': new API (see issue #53485) | ||
--> $DIR/feature-gate-is_sorted.rs:9:26 | ||
| | ||
LL | assert!([1, 2, 2, 9].is_sorted()); | ||
| ^^^^^^^^^ | ||
| | ||
= help: add #![feature(is_sorted)] to the crate attributes to enable | ||
|
||
error[E0658]: use of unstable library feature 'is_sorted': new API (see issue #53485) | ||
--> $DIR/feature-gate-is_sorted.rs:11:32 | ||
| | ||
LL | assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs())); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= help: add #![feature(is_sorted)] to the crate attributes to enable | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |