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:
bors 2018-10-07 22:00:04 +00:00
commit b9adc3327e

View File

@ -212,6 +212,19 @@ impl ErrorKind {
/// the heap (for normal construction via Error::new) is too costly.
#[stable(feature = "io_error_from_errorkind", since = "1.14.0")]
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]
fn from(kind: ErrorKind) -> Error {
Error {