fn find_path_deps(cargo_metadata: &Metadata) -> Result<HashMap<&String, &PathBuf>> {
    let root = cargo_metadata
        .root_package()
        .context("Expected the dependency graph to have a root package")?;
    // scan the dependency graph for path dependencies
    let mut path_deps = HashMap::new();
    let mut stack: Vec<&cargo_metadata::Package> = vec![root];
    while let Some(top) = stack.pop() {
        for dependency in &top.dependencies {
            if let Some(path) = &dependency.path {
                path_deps.insert(&dependency.name, path);
                // we search for the respective package by `manifest_path`, there seems
                // to be no way to query the dependency graph given `dependency`
                let dep_manifest_path = path.join("Cargo.toml");
                let dep_package = cargo_metadata
                    .packages
                    .iter()
                    .find(|package| package.manifest_path == dep_manifest_path)
                    .context(format!(
                        "Expected metadata to contain a package for path dependency {:?}",
                        path
                    ))?;
                // scan the dependencies of the path dependency
                stack.push(dep_package)
            }
        }
    }
    Ok(path_deps)
}
/// Finds all path dependencies of the crate.
Finds all path dependencies of the crate.
Finds all path dependencies of the crate .
fn find_path_deps(cargo_metadata: &Metadata) -> Result<HashMap<&String, &PathBuf>> {
    let root = cargo_metadata
        .root_package()
        .context("Expected the dependency graph to have a root package")?;
    // scan the dependency graph for path dependencies
    let mut path_deps = HashMap::new();
    let mut stack: Vec<&cargo_metadata::Package> = vec![root];
    while let Some(top) = stack.pop() {
        for dependency in &top.dependencies {
            if let Some(path) = &dependency.path {
                path_deps.insert(&dependency.name, path);
                // we search for the respective package by `manifest_path`, there seems
                // to be no way to query the dependency graph given `dependency`
                let dep_manifest_path = path.join("Cargo.toml");
                let dep_package = cargo_metadata
                    .packages
                    .iter()
                    .find(|package| package.manifest_path == dep_manifest_path)
                    .context(format!(
                        "Expected metadata to contain a package for path dependency {:?}",
                        path
                    ))?;
                // scan the dependencies of the path dependency
                stack.push(dep_package)
            }
        }
    }
    Ok(path_deps)
}
fn find_path_deps ( cargo_metadata : & Metadata ) -> Result < HashMap < & String , & PathBuf > > { let root = cargo_metadata . root_package ( ) . context ( " " ) ? ; // scan the dependency graph for path dependencies let mut path_deps = HashMap :: new ( ) ; let mut stack : Vec < & cargo_metadata :: Package > = vec ! [ root ] ; while let Some ( top ) = stack . pop ( ) { for dependency in & top . dependencies { if let Some ( path ) = & dependency . path { path_deps . insert ( & dependency . name , path ) ; // we search for the respective package by `manifest_path`, there seems // to be no way to query the dependency graph given `dependency` let dep_manifest_path = path . join ( " " ) ; let dep_package = cargo_metadata . packages . iter ( ) . find ( | package | package . manifest_path == dep_manifest_path ) . context ( format ! ( " " path ) ) ? ; // scan the dependencies of the path dependency stack . push ( dep_package ) } } } Ok ( path_deps ) }
Finds all path dependencies of the crate.
Finds all path dependencies of the crate .
cargo_metadata
&Metadata
cargo_metadata
&Metadata