about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-07-02 09:50:19 -0400
committerCorey Farwell <coreyf@rwell.org>2016-07-06 19:39:21 -0400
commit98e3120ad218b8d9c50e25a525dcff689c515776 (patch)
treeb1b3732801ed46fc86313d119f8ea09555426738 /src/libstd/io
parent01411937ff6b2a2dfad03d060d636941b0034591 (diff)
downloadrust-98e3120ad218b8d9c50e25a525dcff689c515776.tar.gz
rust-98e3120ad218b8d9c50e25a525dcff689c515776.zip
Add doc examples for `io::Error::from_raw_os_error`.
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/error.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index e142c78569b..05ae8ed5b0b 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -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) }