Skip to content

Commit

Permalink
Auto merge of #123851 - NobodyXu:patch-1, r=BurntSushi
Browse files Browse the repository at this point in the history
Update document for std::io::Error::downcast

Resolve concern raised by `@BurntSushi` #99262 (comment)
  • Loading branch information
bors committed Apr 15, 2024
2 parents d493fd1 + 05366ee commit 84e729a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions library/std/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down

0 comments on commit 84e729a

Please sign in to comment.