about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJiahao XU <Jiahao_XU@outlook.com>2022-07-14 11:24:44 +1000
committerJiahao XU <Jiahao_XU@outlook.com>2022-07-14 11:24:44 +1000
commit111253c519adc17f5bbfa41b7368512ac7e1effd (patch)
treea735b2d18db5009805a7766df31229a59476ea53
parent516da4c93f804f27b1a5f664ae06b9054532f095 (diff)
downloadrust-111253c519adc17f5bbfa41b7368512ac7e1effd.tar.gz
rust-111253c519adc17f5bbfa41b7368512ac7e1effd.zip
Rename `std::io::Error::try_downcast_inner` to `downcast`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
-rw-r--r--library/std/src/io/error.rs8
-rw-r--r--library/std/src/io/error/tests.rs14
2 files changed, 11 insertions, 11 deletions
diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs
index 4c6fd55ad13..8f2119425d1 100644
--- a/library/std/src/io/error.rs
+++ b/library/std/src/io/error.rs
@@ -808,7 +808,7 @@ impl Error {
     /// # Examples
     ///
     /// ```
-    /// #![feature(io_error_try_downcast_inner)]
+    /// #![feature(io_error_downcast)]
     ///
     /// use std::fmt;
     /// use std::io;
@@ -829,14 +829,14 @@ impl Error {
     ///
     /// impl From<io::Error> for E {
     ///     fn from(err: io::Error) -> E {
-    ///         err.try_downcast_inner::<E>()
+    ///         err.downcast::<E>()
     ///             .map(|b| *b)
     ///             .unwrap_or_else(E::Io)
     ///     }
     /// }
     /// ```
-    #[unstable(feature = "io_error_try_downcast_inner", issue = "none")]
-    pub fn try_downcast_inner<E>(self) -> result::Result<Box<E>, Self>
+    #[unstable(feature = "io_error_downcast", issue = "none")]
+    pub fn downcast<E>(self) -> result::Result<Box<E>, Self>
     where
         E: error::Error + Send + Sync + 'static,
     {
diff --git a/library/std/src/io/error/tests.rs b/library/std/src/io/error/tests.rs
index 558594c816e..c897a5e8701 100644
--- a/library/std/src/io/error/tests.rs
+++ b/library/std/src/io/error/tests.rs
@@ -154,32 +154,32 @@ impl fmt::Display for E {
 impl error::Error for E {}
 
 #[test]
-fn test_try_downcast_inner() {
+fn test_std_io_error_downcast() {
     // Case 1: custom error, downcast succeeds
     let io_error = Error::new(ErrorKind::Other, Bojji(true));
-    let e: Box<Bojji> = io_error.try_downcast_inner().unwrap();
+    let e: Box<Bojji> = io_error.downcast().unwrap();
     assert!(e.0);
 
     // Case 2: custom error, downcast fails
     let io_error = Error::new(ErrorKind::Other, Bojji(true));
-    let io_error = io_error.try_downcast_inner::<E>().unwrap_err();
+    let io_error = io_error.downcast::<E>().unwrap_err();
 
     //   ensures that the custom error is intact
     assert_eq!(ErrorKind::Other, io_error.kind());
-    let e: Box<Bojji> = io_error.try_downcast_inner().unwrap();
+    let e: Box<Bojji> = io_error.downcast().unwrap();
     assert!(e.0);
 
     // Case 3: os error
     let errno = 20;
     let io_error = Error::from_raw_os_error(errno);
-    let io_error = io_error.try_downcast_inner::<E>().unwrap_err();
+    let io_error = io_error.downcast::<E>().unwrap_err();
 
     assert_eq!(errno, io_error.raw_os_error().unwrap());
 
     // Case 4: simple
     let kind = ErrorKind::OutOfMemory;
     let io_error: Error = kind.into();
-    let io_error = io_error.try_downcast_inner::<E>().unwrap_err();
+    let io_error = io_error.downcast::<E>().unwrap_err();
 
     assert_eq!(kind, io_error.kind());
 
@@ -187,7 +187,7 @@ fn test_try_downcast_inner() {
     const SIMPLE_MESSAGE: SimpleMessage =
         SimpleMessage { kind: ErrorKind::Other, message: "simple message error test" };
     let io_error = Error::from_static_message(&SIMPLE_MESSAGE);
-    let io_error = io_error.try_downcast_inner::<E>().unwrap_err();
+    let io_error = io_error.downcast::<E>().unwrap_err();
 
     assert_eq!(SIMPLE_MESSAGE.kind, io_error.kind());
     assert_eq!(SIMPLE_MESSAGE.message, &*format!("{io_error}"));