about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <andersrb@gmail.com>2020-02-05 16:28:13 +0800
committerBrian Anderson <andersrb@gmail.com>2020-02-05 16:28:13 +0800
commitc00d8aa5179ef38f7d83067a8d010bcc26fa0cc3 (patch)
treecc6b233e2980bfef35e4e80ce89bc17bbeab7a7e
parent002287d25f6ef9718dbabd3e23c00b5ebcfb51c1 (diff)
downloadrust-c00d8aa5179ef38f7d83067a8d010bcc26fa0cc3.tar.gz
rust-c00d8aa5179ef38f7d83067a8d010bcc26fa0cc3.zip
Reorder declarations of Result::export/unwrap to match Option
-rw-r--r--src/libcore/result.rs34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index bc70dbd62eb..3361ab6c97d 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -935,8 +935,8 @@ impl<T, E: fmt::Debug> Result<T, E> {
     ///
     /// # Panics
     ///
-    /// Panics if the value is an [`Err`], with a panic message provided by the
-    /// [`Err`]'s value.
+    /// Panics if the value is an [`Err`], with a panic message including the
+    /// passed message, and the content of the [`Err`].
     ///
     /// [`Ok`]: enum.Result.html#variant.Ok
     /// [`Err`]: enum.Result.html#variant.Err
@@ -945,22 +945,17 @@ impl<T, E: fmt::Debug> Result<T, E> {
     ///
     /// Basic usage:
     ///
-    /// ```
-    /// let x: Result<u32, &str> = Ok(2);
-    /// assert_eq!(x.unwrap(), 2);
-    /// ```
-    ///
     /// ```{.should_panic}
     /// let x: Result<u32, &str> = Err("emergency failure");
-    /// x.unwrap(); // panics with `emergency failure`
+    /// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
     /// ```
     #[inline]
     #[track_caller]
-    #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn unwrap(self) -> T {
+    #[stable(feature = "result_expect", since = "1.4.0")]
+    pub fn expect(self, msg: &str) -> T {
         match self {
             Ok(t) => t,
-            Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", &e),
+            Err(e) => unwrap_failed(msg, &e),
         }
     }
 
@@ -968,8 +963,8 @@ impl<T, E: fmt::Debug> Result<T, E> {
     ///
     /// # Panics
     ///
-    /// Panics if the value is an [`Err`], with a panic message including the
-    /// passed message, and the content of the [`Err`].
+    /// Panics if the value is an [`Err`], with a panic message provided by the
+    /// [`Err`]'s value.
     ///
     /// [`Ok`]: enum.Result.html#variant.Ok
     /// [`Err`]: enum.Result.html#variant.Err
@@ -978,17 +973,22 @@ impl<T, E: fmt::Debug> Result<T, E> {
     ///
     /// Basic usage:
     ///
+    /// ```
+    /// let x: Result<u32, &str> = Ok(2);
+    /// assert_eq!(x.unwrap(), 2);
+    /// ```
+    ///
     /// ```{.should_panic}
     /// let x: Result<u32, &str> = Err("emergency failure");
-    /// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
+    /// x.unwrap(); // panics with `emergency failure`
     /// ```
     #[inline]
     #[track_caller]
-    #[stable(feature = "result_expect", since = "1.4.0")]
-    pub fn expect(self, msg: &str) -> T {
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn unwrap(self) -> T {
         match self {
             Ok(t) => t,
-            Err(e) => unwrap_failed(msg, &e),
+            Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", &e),
         }
     }
 }