cargo-bin-file
Small helper for reading binary paths from Cargo's
CARGO_BIN_FILE_* environment variables.
This is useful in integration tests or benchmarks where Cargo exposes the path to a compiled binary from another package.
What it does
Given a crate name like example-crate, this crate looks up:
CARGO_BIN_FILE_EXAMPLE_CRATE
If that environment variable exists, it returns the value as a PathBuf.
Otherwise it returns None.
Example
use bin_path;
let key = "CARGO_BIN_FILE_EXAMPLE_CRATE";
unsafe
assert_eq!;
unsafe
Notes
- Hyphens in crate names are converted to underscores.
- ASCII letters are uppercased to match Cargo's environment variable format.
- This crate only reads the environment variable. It does not check whether the resulting path exists.
- The library currently exposes a single helper,
bin_path, for looking up a path by binary crate name.
License
Licensed under either of:
- MIT
- Apache-2.0