Rollup merge of #34612 - frewsxcv:io-error-from_raw_os_error, r=steveklabnik
Add doc examples for `io::Error::from_raw_os_error`. None
This commit is contained in:
commit
75276f36fe
|
@ -214,6 +214,30 @@ impl Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new instance of an `Error` from a particular OS error code.
|
/// Creates a new instance of an `Error` from a particular OS error code.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// On Linux:
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// # if cfg!(target_os = "linux") {
|
||||||
|
/// use std::io;
|
||||||
|
///
|
||||||
|
/// let error = io::Error::from_raw_os_error(98);
|
||||||
|
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
|
||||||
|
/// # }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// On Windows:
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// # if cfg!(windows) {
|
||||||
|
/// use std::io;
|
||||||
|
///
|
||||||
|
/// let error = io::Error::from_raw_os_error(10048);
|
||||||
|
/// assert_eq!(error.kind(), io::ErrorKind::AddrInUse);
|
||||||
|
/// # }
|
||||||
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn from_raw_os_error(code: i32) -> Error {
|
pub fn from_raw_os_error(code: i32) -> Error {
|
||||||
Error { repr: Repr::Os(code) }
|
Error { repr: Repr::Os(code) }
|
||||||
|
|
Loading…
Reference in New Issue