about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorBrian Anderson <andersrb@gmail.com>2020-02-05 16:31:12 +0800
committerBrian Anderson <andersrb@gmail.com>2020-02-05 16:31:12 +0800
commitdb9b578b71190540cfd84f16f5d310d6ce4cb659 (patch)
tree0671d8d006f16ecda7e1fc9c3fe896e8365262db /src/libcore
parentc00d8aa5179ef38f7d83067a8d010bcc26fa0cc3 (diff)
Reorder declarations of Result::expect_err/unwrap_err to match Option
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/result.rs44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 3361ab6c97d..ee28946f0da 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -998,30 +998,26 @@ impl<T: fmt::Debug, E> Result<T, E> {
     ///
     /// # Panics
     ///
-    /// Panics if the value is an [`Ok`], with a custom panic message provided
-    /// by the [`Ok`]'s value.
+    /// Panics if the value is an [`Ok`], with a panic message including the
+    /// passed message, and the content of the [`Ok`].
     ///
     /// [`Ok`]: enum.Result.html#variant.Ok
     /// [`Err`]: enum.Result.html#variant.Err
     ///
-    ///
     /// # Examples
     ///
-    /// ```{.should_panic}
-    /// let x: Result<u32, &str> = Ok(2);
-    /// x.unwrap_err(); // panics with `2`
-    /// ```
+    /// Basic usage:
     ///
-    /// ```
-    /// let x: Result<u32, &str> = Err("emergency failure");
-    /// assert_eq!(x.unwrap_err(), "emergency failure");
+    /// ```{.should_panic}
+    /// let x: Result<u32, &str> = Ok(10);
+    /// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
     /// ```
     #[inline]
     #[track_caller]
-    #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn unwrap_err(self) -> E {
+    #[stable(feature = "result_expect_err", since = "1.17.0")]
+    pub fn expect_err(self, msg: &str) -> E {
         match self {
-            Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", &t),
+            Ok(t) => unwrap_failed(msg, &t),
             Err(e) => e,
         }
     }
@@ -1030,26 +1026,30 @@ impl<T: fmt::Debug, E> Result<T, E> {
     ///
     /// # Panics
     ///
-    /// Panics if the value is an [`Ok`], with a panic message including the
-    /// passed message, and the content of the [`Ok`].
+    /// Panics if the value is an [`Ok`], with a custom panic message provided
+    /// by the [`Ok`]'s value.
     ///
     /// [`Ok`]: enum.Result.html#variant.Ok
     /// [`Err`]: enum.Result.html#variant.Err
     ///
-    /// # Examples
     ///
-    /// Basic usage:
+    /// # Examples
     ///
     /// ```{.should_panic}
-    /// let x: Result<u32, &str> = Ok(10);
-    /// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
+    /// let x: Result<u32, &str> = Ok(2);
+    /// x.unwrap_err(); // panics with `2`
+    /// ```
+    ///
+    /// ```
+    /// let x: Result<u32, &str> = Err("emergency failure");
+    /// assert_eq!(x.unwrap_err(), "emergency failure");
     /// ```
     #[inline]
     #[track_caller]
-    #[stable(feature = "result_expect_err", since = "1.17.0")]
-    pub fn expect_err(self, msg: &str) -> E {
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn unwrap_err(self) -> E {
         match self {
-            Ok(t) => unwrap_failed(msg, &t),
+            Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", &t),
             Err(e) => e,
         }
     }