pub fn crate_name(orig_name: &str) -> Result<FoundCrate, Error>
Expand description

Find the crate name for the given orig_name in the current Cargo.toml.

orig_name should be the original name of the searched crate.

The current Cargo.toml is determined by taking CARGO_MANIFEST_DIR/Cargo.toml.

Returns

  • Ok(orig_name) if the crate was found, but not renamed in the Cargo.toml.
  • Ok(RENAMED) if the crate was found, but is renamed in the Cargo.toml. RENAMED will be the renamed name.
  • Err if an error occurred.

The returned crate name is sanitized in such a way that it is a valid rust identifier. Thus, it is ready to be used in extern crate as identifier.