Macro cargo_metadata

Source
macro_rules! cargo_metadata {
    () => { ... };
    (default = $placeholder:literal) => { ... };
}
Expand description

Macro to generate a ProgramMetadata structure using information from Cargo.

The metadata is retrieved from environment variables set by Cargo. If any of the expected environment variables are not set, compilation will fail. To avoid this, you can provide a default placeholder by providing default = "..." as arguments to the macro. The string literal can contain any value.

§Examples

// This will fail to compile because examples don't have CARGO_BIN_NAME set.
let m = cargo_metadata!();
let m = cargo_metadata!(default = "");
assert_eq!(m.package, "crashlog");
assert_eq!(m.binary, "");