File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -361,13 +361,29 @@ impl ErrorKind {
361361 }
362362}
363363
364+ #[ stable( feature = "io_errorkind_display" , since = "1.60.0" ) ]
365+ impl fmt:: Display for ErrorKind {
366+ /// Shows a human-readable description of the `ErrorKind`.
367+ ///
368+ /// This is similar to `impl Display for Error`, but doesn't require first converting to Error.
369+ ///
370+ /// # Examples
371+ /// ```
372+ /// use std::io::ErrorKind;
373+ /// assert_eq!("entity not found", ErrorKind::NotFound.to_string());
374+ /// ```
375+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
376+ fmt. write_str ( self . as_str ( ) )
377+ }
378+ }
379+
364380/// Intended for use for errors not exposed to the user, where allocating onto
365381/// the heap (for normal construction via Error::new) is too costly.
366382#[ stable( feature = "io_error_from_errorkind" , since = "1.14.0" ) ]
367383impl From < ErrorKind > for Error {
368384 /// Converts an [`ErrorKind`] into an [`Error`].
369385 ///
370- /// This conversion allocates a new error with a simple representation of error kind.
386+ /// This conversion creates a new error with a simple representation of error kind.
371387 ///
372388 /// # Examples
373389 ///
You can’t perform that action at this time.
0 commit comments