crate_name

Function crate_name 

Source
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(FoundCrate::Itself) the searched crate is the current crate being compiled.
  • Ok(FoundCrate::Name(new_name)) the searched create was found with the given name in the Cargo.toml.
  • Err if an error occurred. See Error.

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.