Skip to content

Commit

Permalink
Rollup merge of rust-lang#34612 - frewsxcv:io-error-from_raw_os_error…
Browse files Browse the repository at this point in the history
…, r=steveklabnik

Add doc examples for `io::Error::from_raw_os_error`.

None
  • Loading branch information
Manishearth committed Jul 8, 2016
2 parents 5fedd9c + 98e3120 commit 28ed0ca
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/libstd/io/error.rs
Expand Up @@ -214,6 +214,30 @@ impl Error {
}

/// 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")]
pub fn from_raw_os_error(code: i32) -> Error {
Error { repr: Repr::Os(code) }
Expand Down

0 comments on commit 28ed0ca

Please sign in to comment.