Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions library/core/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use crate::fmt;
/// This list is intended to grow over time and it is not recommended to
/// exhaustively match against it.
///
/// It is used with the [`io::Error`][error] type.
///
/// [error]: ../../std/io/struct.Error.html
///
/// # Handling errors and matching on `ErrorKind`
///
/// In application code, use `match` for the `ErrorKind` values you are
Expand Down Expand Up @@ -121,12 +125,13 @@ pub enum ErrorKind {
#[stable(feature = "rust1", since = "1.0.0")]
TimedOut,
/// An error returned when an operation could not be completed because a
/// call to an underlying writer returned [`Ok(0)`].
/// call to [`write`][write] returned [`Ok(0)`].
///
/// This typically means that an operation could only succeed if it wrote a
/// particular number of bytes but only a smaller number of bytes could be
/// written.
///
/// [write]: ../../std/io/trait.Write.html#tymethod.write
/// [`Ok(0)`]: Ok
#[stable(feature = "rust1", since = "1.0.0")]
WriteZero,
Expand Down Expand Up @@ -225,14 +230,16 @@ pub enum ErrorKind {
//
/// A custom error that does not fall under any other I/O error kind.
///
/// This can be used to construct your own errors that do not match any
/// This can be used to construct your own [`Error`][error]s that do not match any
/// [`ErrorKind`].
///
/// This [`ErrorKind`] is not used by the standard library.
///
/// Errors from the standard library that do not fall under any of the I/O
/// error kinds cannot be `match`ed on, and will only match a wildcard (`_`) pattern.
/// New [`ErrorKind`]s might be added in the future for some of those.
///
/// [error]: ../../std/io/struct.Error.html
#[stable(feature = "rust1", since = "1.0.0")]
Other,

Expand Down Expand Up @@ -365,7 +372,15 @@ impl ErrorKind {

#[stable(feature = "io_errorkind_display", since = "1.60.0")]
impl fmt::Display for ErrorKind {
/// Shows a human-readable description of the `ErrorKind`.
/// Shows a human-readable description of the [`ErrorKind`].
///
/// This is similar to `impl Display for Error`, but doesn't require first converting to Error.
///
/// # Examples
/// ```
/// use core::io::ErrorKind;
/// assert_eq!("entity not found", ErrorKind::NotFound.to_string());
/// ```
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.write_str(self.as_str())
}
Expand Down
Loading