pub fn new(crate_path: &Path, out_name: Option<String>) -> Result<CrateData, Error> {
        let manifest_path = crate_path.join("Cargo.toml");
        if !manifest_path.is_file() {
            bail!(
                "crate directory is missing a `Cargo.toml` file; is `{}` the \
                 wrong directory?",
                crate_path.display()
            )
        }

        let data = cargo_metadata::MetadataCommand::new()
            .manifest_path(&manifest_path)
            .exec()?;

        let manifest_and_keys = CrateData::parse_crate_data(&manifest_path)?;
        CrateData::warn_for_unused_keys(&manifest_and_keys);

        let manifest = manifest_and_keys.manifest;
        let current_idx = data
            .packages
            .iter()
            .position(|pkg| {
                pkg.name == manifest.package.name
                    && CrateData::is_same_path(&pkg.manifest_path, &manifest_path)
            })
            .ok_or_else(|| format_err!("failed to find package in metadata"))?;

        Ok(CrateData {
            data,
            manifest,
            current_idx,
            out_name,
        })
    }
/// Reads all metadata for the crate whose manifest is inside the directory
/// specified by `path`.
Reads all metadata for the crate whose manifest is inside the directory
specified by `path`.
Reads all metadata for the crate whose manifest is inside the directory specified by ` path ` .
pub fn new(crate_path: &Path, out_name: Option<String>) -> Result<CrateData, Error> {
        let manifest_path = crate_path.join("Cargo.toml");
        if !manifest_path.is_file() {
            bail!(
                "crate directory is missing a `Cargo.toml` file; is `{}` the \
                 wrong directory?",
                crate_path.display()
            )
        }
        let data = cargo_metadata::MetadataCommand::new()
            .manifest_path(&manifest_path)
            .exec()?;
        let manifest_and_keys = CrateData::parse_crate_data(&manifest_path)?;
        CrateData::warn_for_unused_keys(&manifest_and_keys);
        let manifest = manifest_and_keys.manifest;
        let current_idx = data
            .packages
            .iter()
            .position(|pkg| {
                pkg.name == manifest.package.name
                    && CrateData::is_same_path(&pkg.manifest_path, &manifest_path)
            })
            .ok_or_else(|| format_err!("failed to find package in metadata"))?;
        Ok(CrateData {
            data,
            manifest,
            current_idx,
            out_name,
        })
    }
pub fn new ( crate_path : & Path , out_name : Option < String > ) -> Result < CrateData , Error > { let manifest_path = crate_path . join ( " " ) ; if ! manifest_path . is_file ( ) { bail ! ( " \
 " crate_path display ( ) ) } let data = cargo_metadata :: MetadataCommand :: new ( ) . manifest_path ( & manifest_path ) . exec ( ) ? ; let manifest_and_keys = CrateData :: parse_crate_data ( & manifest_path ) ? ; CrateData :: warn_for_unused_keys ( & manifest_and_keys ) ; let manifest = manifest_and_keys . manifest ; let current_idx = data . packages . iter ( ) . position ( | pkg | { pkg . name == manifest . package . name && CrateData :: is_same_path ( & pkg . manifest_path , & manifest_path ) } ) . ok_or_else ( | | format_err ! ( " " ) ) ? ; Ok ( CrateData { data , manifest , current_idx , out_name , } ) }
Reads all metadata for the crate whose manifest is inside the directory
specified by `path`.
Reads all metadata for the crate whose manifest is inside the directory specified by ` path ` .
crate_path
&Path
out_name
Option<String>