Auto merge of #123851 - NobodyXu:patch-1, r=BurntSushi

Update document for std::io::Error::downcast

Resolve concern raised by `@BurntSushi` https://github.com/rust-lang/rust/issues/99262#issuecomment-2042641813
This commit is contained in:
bors 2024-04-15 12:32:57 +00:00
commit 84e729a59f

View File

@ -852,15 +852,19 @@ 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`] 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`].
///
/// This method is meant to be a convenience routine for calling
/// `Box<dyn Error + Sync + Send>::downcast` on the custom boxed error, returned by
/// [`Error::into_inner`].
///
/// [`new`]: Error::new
///
/// # Examples
///