]> git.lizzy.rs Git - rust.git/commitdiff
std: Stabilize io::Error::from_raw_os_error
authorAlex Crichton <alex@alexcrichton.com>
Wed, 8 Apr 2015 23:41:14 +0000 (16:41 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 8 Apr 2015 23:49:49 +0000 (16:49 -0700)
This commit stabilizes the old `io::Error::from_os_error` after being renamed to
use the `raw_os_error` terminology instead. This function is often useful when
writing bindings to OS functions but only actually converting to an I/O error at
a later point.

src/libstd/io/error.rs
src/libstd/sys/unix/process2.rs
src/libstd/sys/unix/thread.rs
src/libstd/sys/windows/net.rs

index b84dcb8fb620616f256927c8d68e69b8567ba0e9..7428d0a8e35ef1820a35bcf461437bc995771109 100644 (file)
@@ -163,12 +163,18 @@ pub fn new<E>(kind: ErrorKind, error: E) -> Error
     /// `Error` for the error code.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn last_os_error() -> Error {
-        Error::from_os_error(sys::os::errno() as i32)
+        Error::from_raw_os_error(sys::os::errno() as i32)
     }
 
     /// Creates a new instance of an `Error` from a particular OS error code.
-    #[unstable(feature = "io",
-               reason = "unclear whether this function is necessary")]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub fn from_raw_os_error(code: i32) -> Error {
+        Error { repr: Repr::Os(code) }
+    }
+
+    /// Creates a new instance of an `Error` from a particular OS error code.
+    #[unstable(feature = "io", reason = "deprecated")]
+    #[deprecated(since = "1.0.0", reason = "renamed to from_raw_os_error")]
     pub fn from_os_error(code: i32) -> Error {
         Error { repr: Repr::Os(code) }
     }
index c2a8b26aef4ebb63306fa9f6b947f9c3df15e99e..60f00c80b4abdbf61b42b7020627a9603f28121a 100644 (file)
@@ -193,7 +193,7 @@ fn combine(arr: &[u8]) -> i32 {
                                 let errno = combine(&bytes[0.. 4]);
                                 assert!(p.wait().is_ok(),
                                         "wait() should either return Ok or panic");
-                                return Err(Error::from_os_error(errno))
+                                return Err(Error::from_raw_os_error(errno))
                             }
                             Ok(0) => return Ok(p),
                             Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
index eb61f21aacd5d52ee5a7c66106948e90ac835287..73d6cd73621ad6ed39be674112663e01a2ff8bb5 100644 (file)
@@ -212,7 +212,7 @@ pub unsafe fn create(stack: usize, p: Thunk) -> io::Result<rust_thread> {
     assert_eq!(pthread_attr_destroy(&mut attr), 0);
 
     return if ret != 0 {
-        Err(io::Error::from_os_error(ret))
+        Err(io::Error::from_raw_os_error(ret))
     } else {
         mem::forget(p); // ownership passed to pthread_create
         Ok(native)
index 12a8ef99d764adc3a9d70b6eea9c66bb71787ca0..5ced8863e62a905dd137de6e6c9d19dd44f03de5 100644 (file)
@@ -43,7 +43,7 @@ pub fn init() {
 
 /// Returns the last error from the Windows socket interface.
 fn last_error() -> io::Error {
-    io::Error::from_os_error(unsafe { c::WSAGetLastError() })
+    io::Error::from_raw_os_error(unsafe { c::WSAGetLastError() })
 }
 
 /// Checks if the signed integer is the Windows constant `SOCKET_ERROR` (-1)