This commit stabilizes and deprecates library APIs whose FCP has closed in the
last cycle, specifically:
Stabilized APIs:
* `fs::canonicalize`
* `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists,
is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait.
* `Formatter::fill`
* `Formatter::width`
* `Formatter::precision`
* `Formatter::sign_plus`
* `Formatter::sign_minus`
* `Formatter::alternate`
* `Formatter::sign_aware_zero_pad`
* `string::ParseError`
* `Utf8Error::valid_up_to`
* `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}`
* `<[T]>::split_{first,last}{,_mut}`
* `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated
but will be once 1.5 is released.
* `str::{R,}MatchIndices`
* `str::{r,}match_indices`
* `char::from_u32_unchecked`
* `VecDeque::insert`
* `VecDeque::shrink_to_fit`
* `VecDeque::as_slices`
* `VecDeque::as_mut_slices`
* `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`)
* `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`)
* `Vec::resize`
* `str::slice_mut_unchecked`
* `FileTypeExt`
* `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}`
* `BinaryHeap::from` - `from_vec` deprecated in favor of this
* `BinaryHeap::into_vec` - plus a `Into` impl
* `BinaryHeap::into_sorted_vec`
Deprecated APIs
* `slice::ref_slice`
* `slice::mut_ref_slice`
* `iter::{range_inclusive, RangeInclusive}`
* `std::dynamic_lib`
Closes #27706
Closes #27725
cc #27726 (align not stabilized yet)
Closes #27734
Closes #27737
Closes #27742
Closes #27743
Closes #27772
Closes #27774
Closes #27777
Closes #27781
cc #27788 (a few remaining methods though)
Closes #27790
Closes #27793
Closes #27796
Closes #27810
cc #28147 (not all parts stabilized)
97 lines
2.9 KiB
Rust
97 lines
2.9 KiB
Rust
// Copyright 2012 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.
|
|
|
|
#![allow(deprecated)]
|
|
|
|
use std::dynamic_lib::DynamicLibrary;
|
|
use std::io::prelude::*;
|
|
use std::path::PathBuf;
|
|
use std::process::{ExitStatus, Command, Child, Output, Stdio};
|
|
|
|
fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
|
|
// Need to be sure to put both the lib_path and the aux path in the dylib
|
|
// search path for the child.
|
|
let mut path = DynamicLibrary::search_path();
|
|
if let Some(p) = aux_path {
|
|
path.insert(0, PathBuf::from(p))
|
|
}
|
|
path.insert(0, PathBuf::from(lib_path));
|
|
|
|
// Add the new dylib search path var
|
|
let var = DynamicLibrary::envvar();
|
|
let newpath = DynamicLibrary::create_path(&path);
|
|
cmd.env(var, newpath);
|
|
}
|
|
|
|
pub struct Result {pub status: ExitStatus, pub out: String, pub err: String}
|
|
|
|
pub fn run(lib_path: &str,
|
|
prog: &str,
|
|
aux_path: Option<&str>,
|
|
args: &[String],
|
|
env: Vec<(String, String)> ,
|
|
input: Option<String>) -> Option<Result> {
|
|
|
|
let mut cmd = Command::new(prog);
|
|
cmd.args(args)
|
|
.stdin(Stdio::piped())
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped());
|
|
add_target_env(&mut cmd, lib_path, aux_path);
|
|
for (key, val) in env {
|
|
cmd.env(&key, &val);
|
|
}
|
|
|
|
match cmd.spawn() {
|
|
Ok(mut process) => {
|
|
if let Some(input) = input {
|
|
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
|
|
}
|
|
let Output { status, stdout, stderr } =
|
|
process.wait_with_output().unwrap();
|
|
|
|
Some(Result {
|
|
status: status,
|
|
out: String::from_utf8(stdout).unwrap(),
|
|
err: String::from_utf8(stderr).unwrap()
|
|
})
|
|
},
|
|
Err(..) => None
|
|
}
|
|
}
|
|
|
|
pub fn run_background(lib_path: &str,
|
|
prog: &str,
|
|
aux_path: Option<&str>,
|
|
args: &[String],
|
|
env: Vec<(String, String)> ,
|
|
input: Option<String>) -> Option<Child> {
|
|
|
|
let mut cmd = Command::new(prog);
|
|
cmd.args(args)
|
|
.stdin(Stdio::piped())
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped());
|
|
add_target_env(&mut cmd, lib_path, aux_path);
|
|
for (key, val) in env {
|
|
cmd.env(&key, &val);
|
|
}
|
|
|
|
match cmd.spawn() {
|
|
Ok(mut process) => {
|
|
if let Some(input) = input {
|
|
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
|
|
}
|
|
|
|
Some(process)
|
|
},
|
|
Err(..) => None
|
|
}
|
|
}
|