Skip to content

Commit e265e77

Browse files
committed
std: Stabilize portions of std::os::$platform
This commit starts to organize the `std::os::$platform` modules and in the process stabilizes some of the functionality contained within. The organization of these modules will reflect the organization of the standard library itself with extension traits for primitives in the same corresponding module. The OS-specific modules will grow more functionality over time including concrete types that are not extending functionality of other structures, and these will either go into the closest module in `std::os::$platform` or they will grow a new module in the hierarchy. The following items are now stable: * `os::{unix, windows}` * `unix::ffi` * `unix::ffi::OsStrExt` * `unix::ffi::OsStrExt::{from_bytes, as_bytes, to_cstring}` * `unix::ffi::OsString` * `unix::ffi::OsStringExt::{from_vec, into_vec}` * `unix::process` * `unix::process::CommandExt` * `unix::process::CommandExt::{uid, gid}` * `unix::process::ExitStatusExt` * `unix::process::ExitStatusExt::signal` * `unix::prelude` * `windows::ffi` * `windows::ffi::OsStringExt` * `windows::ffi::OsStringExt::from_wide` * `windows::ffi::OsStrExt` * `windows::ffi::OsStrExt::encode_wide` * `windows::prelude` The following items remain unstable: * `unix::io` * `unix::io::{Fd, AsRawFd}` * `unix::fs::{PermissionsExt, OpenOptionsExt}` * `windows::io` * `windows::io::{Handle, AsRawHandle}` * `windows::io::{Socket, AsRawSocket}` * `windows::fs` * `windows::fs::OpenOptionsExt` Due to the reorgnization of the platform extension modules, this commit is a breaking change. Most imports can be fixed by adding the relevant libstd module in the `use` path (such as `ffi` or `fs`). [breaking-change]
1 parent 66853af commit e265e77

File tree

9 files changed

+395
-321
lines changed

9 files changed

+395
-321
lines changed

src/libstd/os.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub fn getenv_as_bytes(n: &str) -> Option<Vec<u8>> {
210210

211211
#[cfg(unix)]
212212
fn byteify(s: OsString) -> Vec<u8> {
213-
use os::unix::*;
213+
use os::unix::prelude::*;
214214
s.into_vec()
215215
}
216216
#[cfg(windows)]
@@ -238,7 +238,7 @@ fn byteify(s: OsString) -> Vec<u8> {
238238
pub fn setenv<T: BytesContainer>(n: &str, v: T) {
239239
#[cfg(unix)]
240240
fn _setenv(n: &str, v: &[u8]) {
241-
use os::unix::*;
241+
use os::unix::prelude::*;
242242
let v: OsString = OsStringExt::from_vec(v.to_vec());
243243
env::set_var(n, &v)
244244
}
@@ -1705,13 +1705,13 @@ mod tests {
17051705

17061706
#[cfg(not(windows))]
17071707
fn get_fd(file: &File) -> libc::c_int {
1708-
use os::unix::AsRawFd;
1708+
use os::unix::prelude::*;
17091709
file.as_raw_fd()
17101710
}
17111711

17121712
#[cfg(windows)]
17131713
fn get_fd(file: &File) -> libc::HANDLE {
1714-
use os::windows::AsRawHandle;
1714+
use os::windows::prelude::*;
17151715
file.as_raw_handle()
17161716
}
17171717

src/libstd/process.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ mod tests {
573573
#[cfg(all(unix, not(target_os="android")))]
574574
#[test]
575575
fn signal_reported_right() {
576-
use os::unix::ExitStatusExt;
576+
use os::unix::process::ExitStatusExt;
577577

578578
let p = Command::new("/bin/sh").arg("-c").arg("kill -9 $$").spawn();
579579
assert!(p.is_ok());

0 commit comments

Comments
 (0)