about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Leimkuhler <kevin@kleimkuhler.com>2018-10-12 14:47:01 -0700
committerKevin Leimkuhler <kevin@kleimkuhler.com>2019-01-17 22:34:43 -0800
commitce47dde59f45d55fa27dce9a614d1a972f9d8a4f (patch)
tree18177d1f5095ade1e718adca6a0cfca73b5c6d6b
parent02477f6f99c22509825a85bd090e42f935b33983 (diff)
downloadrust-ce47dde59f45d55fa27dce9a614d1a972f9d8a4f.tar.gz
rust-ce47dde59f45d55fa27dce9a614d1a972f9d8a4f.zip
Add is_sorted unstable documentation
-rw-r--r--src/doc/unstable-book/src/library-features/is-sorted.md11
-rw-r--r--src/libcore/iter/iterator.rs2
-rw-r--r--src/libcore/slice/mod.rs2
-rw-r--r--src/test/ui/feature-gates/feature-gate-is_sorted.rs7
-rw-r--r--src/test/ui/feature-gates/feature-gate-is_sorted.stderr22
5 files changed, 41 insertions, 3 deletions
diff --git a/src/doc/unstable-book/src/library-features/is-sorted.md b/src/doc/unstable-book/src/library-features/is-sorted.md
new file mode 100644
index 00000000000..e3b7dc3b28e
--- /dev/null
+++ b/src/doc/unstable-book/src/library-features/is-sorted.md
@@ -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`.
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs
index 879cc8357cd..67591381fdc 100644
--- a/src/libcore/iter/iterator.rs
+++ b/src/libcore/iter/iterator.rs
@@ -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
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index d4cac3e4f4b..ab160a6c0c4 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -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
diff --git a/src/test/ui/feature-gates/feature-gate-is_sorted.rs b/src/test/ui/feature-gates/feature-gate-is_sorted.rs
index 82fee379a4f..f44e74838ed 100644
--- a/src/test/ui/feature-gates/feature-gate-is_sorted.rs
+++ b/src/test/ui/feature-gates/feature-gate-is_sorted.rs
@@ -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'
 }
diff --git a/src/test/ui/feature-gates/feature-gate-is_sorted.stderr b/src/test/ui/feature-gates/feature-gate-is_sorted.stderr
index e4c7891760c..873cee53370 100644
--- a/src/test/ui/feature-gates/feature-gate-is_sorted.stderr
+++ b/src/test/ui/feature-gates/feature-gate-is_sorted.stderr
@@ -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`.