Skip to content

Commit b9adc33

Browse files
committed
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.
2 parents b2d6ea9 + 4f3896d commit b9adc33

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: src/libstd/io/error.rs

+13
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,19 @@ impl ErrorKind {
212212
/// the heap (for normal construction via Error::new) is too costly.
213213
#[stable(feature = "io_error_from_errorkind", since = "1.14.0")]
214214
impl From<ErrorKind> for Error {
215+
/// Converts an [`ErrorKind`] into an [`Error`].
216+
///
217+
/// This conversion allocates a new error with a simple representation of error kind.
218+
///
219+
/// # Examples
220+
///
221+
/// ```
222+
/// use std::io::{Error, ErrorKind};
223+
///
224+
/// let not_found = ErrorKind::NotFound;
225+
/// let error = Error::from(not_found);
226+
/// assert_eq!("entity not found", format!("{}", error));
227+
/// ```
215228
#[inline]
216229
fn from(kind: ErrorKind) -> Error {
217230
Error {

0 commit comments

Comments
 (0)