1
Fork 0

std: Add IntoRaw{Fd,Handle,Socket} traits

This commit is an implementation of [RFC 1174][rfc] which adds three new traits
to the standard library:

* `IntoRawFd` - implemented on Unix for all I/O types (files, sockets, etc)
* `IntoRawHandle` - implemented on Windows for files, processes, etc
* `IntoRawSocket` - implemented on Windows for networking types

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1174-into-raw-fd-socket-handle-traits.md

Closes #27062
This commit is contained in:
Alex Crichton 2015-07-15 23:31:24 -07:00
parent 4e51763e64
commit 7e9e3896df
16 changed files with 195 additions and 15 deletions

View file

@ -17,7 +17,7 @@ use str;
use sys::c;
use net::SocketAddr;
use sys::fd::FileDesc;
use sys_common::{AsInner, FromInner};
use sys_common::{AsInner, FromInner, IntoInner};
use sys_common::net::{getsockopt, setsockopt};
use time::Duration;
@ -127,3 +127,7 @@ impl AsInner<c_int> for Socket {
impl FromInner<c_int> for Socket {
fn from_inner(fd: c_int) -> Socket { Socket(FileDesc::new(fd)) }
}
impl IntoInner<c_int> for Socket {
fn into_inner(self) -> c_int { self.0.into_raw() }
}