]> git.lizzy.rs Git - rust.git/commitdiff
Add is_sorted unstable documentation
authorKevin Leimkuhler <kevin@kleimkuhler.com>
Fri, 12 Oct 2018 21:47:01 +0000 (14:47 -0700)
committerKevin Leimkuhler <kevin@kleimkuhler.com>
Fri, 18 Jan 2019 06:34:43 +0000 (22:34 -0800)
src/doc/unstable-book/src/library-features/is-sorted.md [new file with mode: 0644]
src/libcore/iter/iterator.rs
src/libcore/slice/mod.rs
src/test/ui/feature-gates/feature-gate-is_sorted.rs
src/test/ui/feature-gates/feature-gate-is_sorted.stderr

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 (file)
index 0000000..e3b7dc3
--- /dev/null
@@ -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`.
index 879cc8357cd2462e45d071285857b92988a052af..67591381fdc92aeec9488df84b910725ac02de76 100644 (file)
@@ -2626,6 +2626,7 @@ fn ge<I>(mut self, other: I) -> bool where
     /// 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 @@ fn is_sorted_by<F>(mut self, mut compare: F) -> bool
     /// 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
index d4cac3e4f4b8f5c3309183827e4ead6e083035b8..ab160a6c0c406eb50079cdb4c6a5717f5a989777 100644 (file)
@@ -2272,6 +2272,7 @@ pub unsafe fn align_to_mut<U>(&mut self) -> (&mut [T], &mut [U], &mut [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 @@ pub fn is_sorted_by<F>(&self, mut compare: F) -> bool
     /// 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
index 82fee379a4fa7246d721aaf5c29f3fa342eaa4fd..f44e74838ed2364ab1f79ae4afdd9d442677130a 100644 (file)
@@ -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'
 }
index e4c7891760ceab665f2c6937077b2b1e9230cd0f..873cee533705da7684b0957b287f7986a0e6ed0e 100644 (file)
@@ -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`.