From 4a6b1562b5541af7402f7a372b0ad6ee37203a25 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 12 Apr 2024 23:03:36 +1000 Subject: [PATCH 1/2] Update document for std::io::Error::downcast --- library/std/src/io/error.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 4e1d7c2ac65ac..8bd11911fb1e3 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -852,15 +852,15 @@ impl Error { } } - /// Attempt to downcast the inner error to `E` if any. + /// Attempt to downcast the custom boxed error to `E`. /// - /// If this [`Error`] was constructed via [`new`] then this function will - /// attempt to perform downgrade on it, otherwise it will return [`Err`]. + /// If this [`Error`] when this contains a custom boxed error, + /// then it would attempt downcasting on the boxed error, + /// otherwise it will return [`Err`]. /// - /// If the downcast succeeds, it will return [`Ok`], otherwise it will also - /// return [`Err`]. + /// If the custom boxed error has the same type as `E`, it will return [`Ok`], + /// otherwise it will also return [`Err`]. /// - /// [`new`]: Error::new /// /// # Examples /// From 05366ee2707b1f594edf06de3b0e7edb16f0aa94 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Mon, 15 Apr 2024 21:58:36 +1000 Subject: [PATCH 2/2] Update doc for std::io::Error::downcast --- library/std/src/io/error.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 8bd11911fb1e3..21ae7b91207c1 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -854,13 +854,17 @@ impl Error { /// Attempt to downcast the custom boxed error to `E`. /// - /// If this [`Error`] when this contains a custom boxed error, + /// If this [`Error`] contains a custom boxed error, /// then it would attempt downcasting on the boxed error, /// otherwise it will return [`Err`]. /// /// If the custom boxed error has the same type as `E`, it will return [`Ok`], /// otherwise it will also return [`Err`]. /// + /// This method is meant to be a convenience routine for calling + /// `Box::downcast` on the custom boxed error, returned by + /// [`Error::into_inner`]. + /// /// /// # Examples ///