mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-12 23:13:15 +00:00
Add is_sorted unstable documentation
This commit is contained in:
parent
02477f6f99
commit
ce47dde59f
11
src/doc/unstable-book/src/library-features/is-sorted.md
Normal file
11
src/doc/unstable-book/src/library-features/is-sorted.md
Normal file
@ -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`.
|
@ -2626,6 +2626,7 @@ pub trait Iterator {
|
||||
/// assert!(std::iter::empty::<i32>().is_sorted());
|
||||
/// assert!(![0.0, 1.0, std::f32::NAN].iter().is_sorted());
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
||||
fn is_sorted(self) -> bool
|
||||
where
|
||||
@ -2676,6 +2677,7 @@ pub trait Iterator {
|
||||
/// assert!(["c", "bb", "aaa"].iter().is_sorted_by_key(|s| s.len()));
|
||||
/// assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs()));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
||||
fn is_sorted_by_key<F, K>(self, mut f: F) -> bool
|
||||
where
|
||||
|
@ -2272,6 +2272,7 @@ impl<T> [T] {
|
||||
/// assert!(empty.is_sorted());
|
||||
/// assert!(![0.0, 1.0, std::f32::NAN].is_sorted());
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
||||
pub fn is_sorted(&self) -> bool
|
||||
where
|
||||
@ -2319,6 +2320,7 @@ impl<T> [T] {
|
||||
/// assert!(["c", "bb", "aaa"].is_sorted_by_key(|s| s.len()));
|
||||
/// assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs()));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
|
||||
pub fn is_sorted_by_key<F, K>(&self, mut f: F) -> bool
|
||||
where
|
||||
|
@ -9,8 +9,15 @@
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
// Assert `Iterator` methods are feature gated
|
||||
assert!([1, 2, 2, 9].iter().is_sorted());
|
||||
//^ ERROR: use of unstable library feature 'is_sorted'
|
||||
assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs()));
|
||||
//^ ERROR: use of unstable library feature 'is_sorted'
|
||||
|
||||
// Assert `[T]` methods are feature gated
|
||||
assert!([1, 2, 2, 9].is_sorted());
|
||||
//^ ERROR: use of unstable library feature 'is_sorted'
|
||||
assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs()));
|
||||
//^ ERROR: use of unstable library feature 'is_sorted'
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0658]: use of unstable library feature 'is_sorted': new API (see issue #53485)
|
||||
--> $DIR/feature-gate-is_sorted.rs:12:33
|
||||
--> $DIR/feature-gate-is_sorted.rs:13:33
|
||||
|
|
||||
LL | assert!([1, 2, 2, 9].iter().is_sorted());
|
||||
| ^^^^^^^^^
|
||||
@ -7,13 +7,29 @@ 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:14:39
|
||||
--> $DIR/feature-gate-is_sorted.rs:15: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: aborting due to 2 previous errors
|
||||
error[E0658]: use of unstable library feature 'is_sorted': new API (see issue #53485)
|
||||
--> $DIR/feature-gate-is_sorted.rs:19: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:21: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`.
|
||||
|
Loading…
Reference in New Issue
Block a user