File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -361,13 +361,29 @@ impl ErrorKind {
361
361
}
362
362
}
363
363
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
+
364
380
/// Intended for use for errors not exposed to the user, where allocating onto
365
381
/// the heap (for normal construction via Error::new) is too costly.
366
382
#[ stable( feature = "io_error_from_errorkind" , since = "1.14.0" ) ]
367
383
impl From < ErrorKind > for Error {
368
384
/// Converts an [`ErrorKind`] into an [`Error`].
369
385
///
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.
371
387
///
372
388
/// # Examples
373
389
///
You can’t perform that action at this time.
0 commit comments