Merge remote-tracking branch 'rust-lang/master'
Conflicts: src/libcore/cmp.rs src/libcore/fmt/mod.rs src/libcore/iter.rs src/libcore/marker.rs src/libcore/num/f32.rs src/libcore/num/f64.rs src/libcore/result.rs src/libcore/str/mod.rs src/librustc/lint/builtin.rs src/librustc/lint/context.rs src/libstd/sync/mpsc/mod.rs src/libstd/sync/poison.rs
This commit is contained in:
commit
d179ba3b8e
88 changed files with 5485 additions and 559 deletions
|
@ -31,7 +31,10 @@
|
|||
|
||||
#![unstable(feature = "std_misc")]
|
||||
|
||||
use sys_common::AsInner;
|
||||
use vec::Vec;
|
||||
use sys::os_str::Buf;
|
||||
use sys_common::{AsInner, IntoInner, FromInner};
|
||||
use ffi::{OsStr, OsString};
|
||||
use libc;
|
||||
|
||||
use io;
|
||||
|
@ -99,6 +102,36 @@ impl AsRawFd for io::net::udp::UdpSocket {
|
|||
}
|
||||
}
|
||||
|
||||
// Unix-specific extensions to `OsString`.
|
||||
pub trait OsStringExt {
|
||||
/// Create an `OsString` from a byte vector.
|
||||
fn from_vec(vec: Vec<u8>) -> Self;
|
||||
|
||||
/// Yield the underlying byte vector of this `OsString`.
|
||||
fn into_vec(self) -> Vec<u8>;
|
||||
}
|
||||
|
||||
impl OsStringExt for OsString {
|
||||
fn from_vec(vec: Vec<u8>) -> OsString {
|
||||
FromInner::from_inner(Buf { inner: vec })
|
||||
}
|
||||
|
||||
fn into_vec(self) -> Vec<u8> {
|
||||
self.into_inner().inner
|
||||
}
|
||||
}
|
||||
|
||||
// Unix-specific extensions to `OsStr`.
|
||||
pub trait OsStrExt {
|
||||
fn as_byte_slice(&self) -> &[u8];
|
||||
}
|
||||
|
||||
impl OsStrExt for OsStr {
|
||||
fn as_byte_slice(&self) -> &[u8] {
|
||||
&self.as_inner().inner
|
||||
}
|
||||
}
|
||||
|
||||
/// A prelude for conveniently writing platform-specific code.
|
||||
///
|
||||
/// Includes all extension traits, and some important type definitions.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue