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:
parent
4e51763e64
commit
7e9e3896df
16 changed files with 195 additions and 15 deletions
|
@ -24,8 +24,8 @@ use ffi::OsString;
|
|||
use io::{self, SeekFrom, Seek, Read, Write};
|
||||
use path::{Path, PathBuf};
|
||||
use sys::fs as fs_imp;
|
||||
use sys_common::{AsInnerMut, FromInner, AsInner};
|
||||
use sys_common::io::read_to_end_uninitialized;
|
||||
use sys_common::{AsInnerMut, FromInner, AsInner, IntoInner};
|
||||
use vec::Vec;
|
||||
|
||||
/// A reference to an open file on the filesystem.
|
||||
|
@ -317,6 +317,11 @@ impl FromInner<fs_imp::File> for File {
|
|||
File { inner: f }
|
||||
}
|
||||
}
|
||||
impl IntoInner<fs_imp::File> for File {
|
||||
fn into_inner(self) -> fs_imp::File {
|
||||
self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for File {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue