about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-07 22:00:04 +0000
committerbors <bors@rust-lang.org>2018-10-07 22:00:04 +0000
commitb9adc3327ec7d2820ab2db8bb3cc2a0196a8375d (patch)
tree719e8fe0886b3d0b7a31b33c82a3f386bb9944e3 /src/libstd
parentb2d6ea98b0db53889c5427e5a23cddb3bcb63040 (diff)
parent4f3896d8ef381993f333cc7c984991a4590df29f (diff)
downloadrust-b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d.tar.gz
rust-b9adc3327ec7d2820ab2db8bb3cc2a0196a8375d.zip
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.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/error.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index 3e50988a68b..386de080b85 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -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 {