mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-30 12:07:40 +00:00
rustdoc: create rustc command with an iterator
This avoids unnecessary allocation with a temporary Vec.
This commit is contained in:
parent
3d53242e53
commit
713043ef22
@ -307,12 +307,14 @@ fn add_exe_suffix(input: String, target: &TargetTriple) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn wrapped_rustc_command(rustc_wrappers: &[PathBuf], rustc_binary: &Path) -> Command {
|
fn wrapped_rustc_command(rustc_wrappers: &[PathBuf], rustc_binary: &Path) -> Command {
|
||||||
let args: Vec<&Path> =
|
let mut args = rustc_wrappers.iter().map(PathBuf::as_path).chain([rustc_binary].into_iter());
|
||||||
rustc_wrappers.iter().map(PathBuf::as_path).chain([rustc_binary].into_iter()).collect();
|
|
||||||
let (exe, args) = args.split_first().expect("unable to create rustc command");
|
|
||||||
|
|
||||||
|
let exe = args.next().expect("unable to create rustc command");
|
||||||
let mut command = Command::new(exe);
|
let mut command = Command::new(exe);
|
||||||
command.args(args);
|
for arg in args {
|
||||||
|
command.arg(arg);
|
||||||
|
}
|
||||||
|
|
||||||
command
|
command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user