pub trait CommandCargoExtwhere
Self: Sized,{
// Required method
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError>;
}Expand description
Create a Command for a bin in the Cargo project.
CommandCargoExt is an extension trait for Command to easily launch a crate’s
binaries.
See the cargo module documentation for caveats and workarounds.
§Examples
use assert_cmd::prelude::*;
use assert_cmd::pkg_name;
use std::process::Command;
let mut cmd = Command::cargo_bin(pkg_name!())
.unwrap();
let output = cmd.unwrap();
println!("{:?}", output);Required Methods§
Sourcefn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError>
👎Deprecated since 2.1.0: incompatible with a custom cargo build-dir, see instead cargo::cargo_bin!
fn cargo_bin<S: AsRef<str>>(name: S) -> Result<Self, CargoError>
cargo::cargo_bin!Create a Command to run a specific binary of the current crate.
See the cargo module documentation for caveats and workarounds.
The Command created with this method may run the binary through a runner, as configured
in the CARGO_TARGET_<TRIPLET>_RUNNER environment variable. This is useful for running
binaries that can’t be launched directly, such as cross-compiled binaries. When using
this method with cross, no extra configuration is
needed.
NOTE: Prefer cargo_bin! as this makes assumptions about cargo
§Examples
use assert_cmd::prelude::*;
use assert_cmd::pkg_name;
use std::process::Command;
let mut cmd = Command::cargo_bin(pkg_name!())
.unwrap();
let output = cmd.unwrap();
println!("{:?}", output);use assert_cmd::prelude::*;
use std::process::Command;
let mut cmd = Command::cargo_bin("bin_fixture")
.unwrap();
let output = cmd.unwrap();
println!("{:?}", output);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.