run-make: make arg take AsRef<OsStr> instead of str

This commit is contained in:
5225225 2024-04-09 19:55:06 +01:00
parent 65df93bbb4
commit de79a6c084
No known key found for this signature in database
2 changed files with 5 additions and 9 deletions

View File

@ -1,4 +1,5 @@
use std::env;
use std::ffi::OsStr;
use std::path::Path;
use std::process::{Command, Output};
@ -58,18 +59,12 @@ pub fn arg_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self
}
/// Fallback argument provider. Consider adding meaningfully named methods instead of using
/// this method.
pub fn arg(&mut self, arg: &str) -> &mut Self {
/// Generic command argument provider. Use `.arg("-Zname")` over `.arg("-Z").arg("arg")`.
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self {
self.cmd.arg(arg);
self
}
pub fn arg_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
self
}
/// Run the build `rustdoc` command and assert that the run is successful.
#[track_caller]
pub fn run(&mut self) -> Output {

View File

@ -25,7 +25,8 @@ fn main() {
rustdoc()
.arg("success.rs")
.arg("-o").arg_path(tmp_dir().join("exit-code"))
.arg("-o")
.arg(tmp_dir().join("exit-code"))
.run();
rustdoc()