This commit applies the stabilization/deprecations of the 1.16.0 release, as
tracked by the rust-lang/rust issue tracker and the final-comment-period tag.
The following APIs were stabilized:
* `VecDeque::truncate`
* `VecDeque::resize`
* `String::insert_str`
* `Duration::checked_{add,sub,div,mul}`
* `str::replacen`
* `SocketAddr::is_ipv{4,6}`
* `IpAddr::is_ipv{4,6}`
* `str::repeat`
* `Vec::dedup_by`
* `Vec::dedup_by_key`
* `Result::unwrap_or_default`
* `<*const T>::wrapping_offset`
* `<*mut T>::wrapping_offset`
* `CommandExt::creation_flags` (on Windows)
* `File::set_permissions`
* `String::split_off`
The following APIs were deprecated
* `EnumSet` - replaced with other ecosystem abstractions, long since unstable
Closes #27788
Closes #35553
Closes #35774
Closes #36436
Closes #36949
Closes #37079
Closes #37087
Closes #37516
Closes #37827
Closes #37916
Closes #37966
Closes #38080
118 lines
4 KiB
Rust
118 lines
4 KiB
Rust
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
// file at the top-level directory of this distribution and at
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
|
|
//! Extensions to `std::process` for Windows.
|
|
|
|
#![stable(feature = "process_extensions", since = "1.2.0")]
|
|
|
|
use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle};
|
|
use process;
|
|
use sys;
|
|
use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
|
|
|
|
#[stable(feature = "process_extensions", since = "1.2.0")]
|
|
impl FromRawHandle for process::Stdio {
|
|
unsafe fn from_raw_handle(handle: RawHandle) -> process::Stdio {
|
|
let handle = sys::handle::Handle::new(handle as *mut _);
|
|
let io = sys::process::Stdio::Handle(handle);
|
|
process::Stdio::from_inner(io)
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "process_extensions", since = "1.2.0")]
|
|
impl AsRawHandle for process::Child {
|
|
fn as_raw_handle(&self) -> RawHandle {
|
|
self.as_inner().handle().raw() as *mut _
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "into_raw_os", since = "1.4.0")]
|
|
impl IntoRawHandle for process::Child {
|
|
fn into_raw_handle(self) -> RawHandle {
|
|
self.into_inner().into_handle().into_raw() as *mut _
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "process_extensions", since = "1.2.0")]
|
|
impl AsRawHandle for process::ChildStdin {
|
|
fn as_raw_handle(&self) -> RawHandle {
|
|
self.as_inner().handle().raw() as *mut _
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "process_extensions", since = "1.2.0")]
|
|
impl AsRawHandle for process::ChildStdout {
|
|
fn as_raw_handle(&self) -> RawHandle {
|
|
self.as_inner().handle().raw() as *mut _
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "process_extensions", since = "1.2.0")]
|
|
impl AsRawHandle for process::ChildStderr {
|
|
fn as_raw_handle(&self) -> RawHandle {
|
|
self.as_inner().handle().raw() as *mut _
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "into_raw_os", since = "1.4.0")]
|
|
impl IntoRawHandle for process::ChildStdin {
|
|
fn into_raw_handle(self) -> RawHandle {
|
|
self.into_inner().into_handle().into_raw() as *mut _
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "into_raw_os", since = "1.4.0")]
|
|
impl IntoRawHandle for process::ChildStdout {
|
|
fn into_raw_handle(self) -> RawHandle {
|
|
self.into_inner().into_handle().into_raw() as *mut _
|
|
}
|
|
}
|
|
|
|
#[stable(feature = "into_raw_os", since = "1.4.0")]
|
|
impl IntoRawHandle for process::ChildStderr {
|
|
fn into_raw_handle(self) -> RawHandle {
|
|
self.into_inner().into_handle().into_raw() as *mut _
|
|
}
|
|
}
|
|
|
|
/// Windows-specific extensions to `std::process::ExitStatus`
|
|
#[stable(feature = "exit_status_from", since = "1.12.0")]
|
|
pub trait ExitStatusExt {
|
|
/// Creates a new `ExitStatus` from the raw underlying `u32` return value of
|
|
/// a process.
|
|
#[stable(feature = "exit_status_from", since = "1.12.0")]
|
|
fn from_raw(raw: u32) -> Self;
|
|
}
|
|
|
|
#[stable(feature = "exit_status_from", since = "1.12.0")]
|
|
impl ExitStatusExt for process::ExitStatus {
|
|
fn from_raw(raw: u32) -> Self {
|
|
process::ExitStatus::from_inner(From::from(raw))
|
|
}
|
|
}
|
|
|
|
/// Windows-specific extensions to the `std::process::Command` builder
|
|
#[stable(feature = "windows_process_extensions", since = "1.16.0")]
|
|
pub trait CommandExt {
|
|
/// Sets the [process creation flags][1] to be passed to `CreateProcess`.
|
|
///
|
|
/// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`.
|
|
/// [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
|
|
#[stable(feature = "windows_process_extensions", since = "1.16.0")]
|
|
fn creation_flags(&mut self, flags: u32) -> &mut process::Command;
|
|
}
|
|
|
|
#[stable(feature = "windows_process_extensions", since = "1.16.0")]
|
|
impl CommandExt for process::Command {
|
|
fn creation_flags(&mut self, flags: u32) -> &mut process::Command {
|
|
self.as_inner_mut().creation_flags(flags);
|
|
self
|
|
}
|
|
}
|