Auto merge of #53517 - phungleson:fix-impl-from-for-error, r=frewsxcv
Add doc for impl From for Error As part of issue #51430 (cc @skade). The impl is very simple, let me know if we need to go into any details.
This commit is contained in:
commit
b9adc3327e
1 changed files with 13 additions and 0 deletions
|
@ -212,6 +212,19 @@ impl ErrorKind {
|
||||||
/// the heap (for normal construction via Error::new) is too costly.
|
/// the heap (for normal construction via Error::new) is too costly.
|
||||||
#[stable(feature = "io_error_from_errorkind", since = "1.14.0")]
|
#[stable(feature = "io_error_from_errorkind", since = "1.14.0")]
|
||||||
impl From<ErrorKind> for Error {
|
impl From<ErrorKind> for Error {
|
||||||
|
/// Converts an [`ErrorKind`] into an [`Error`].
|
||||||
|
///
|
||||||
|
/// This conversion allocates a new error with a simple representation of error kind.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::io::{Error, ErrorKind};
|
||||||
|
///
|
||||||
|
/// let not_found = ErrorKind::NotFound;
|
||||||
|
/// let error = Error::from(not_found);
|
||||||
|
/// assert_eq!("entity not found", format!("{}", error));
|
||||||
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(kind: ErrorKind) -> Error {
|
fn from(kind: ErrorKind) -> Error {
|
||||||
Error {
|
Error {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue