fn new(
        from_id: &'g PackageId,
        package_data: &'g HashMap<PackageId, (NodeIndex<PackageIx>, String, Version)>,
        package_deps: impl IntoIterator<Item = &'g Dependency>,
    ) -> Self {
        let mut renamed_map = HashMap::new();
        let mut original_map: HashMap<_, DependencyReqs<'g>> = HashMap::new();

        for dep in package_deps {
            match &dep.rename {
                // The rename != dep.name check is because of Cargo.toml instances like this:
                //
                // [dependencies]
                // datatest = "0.4.2"
                //
                // [build-dependencies]
                // datatest = { package = "datatest", version = "0.4.2" }
                //
                // cargo seems to accept such cases if the name doesn't contain a hyphen.
                Some(rename) if rename != &dep.name => {
                    // The resolved name is the same as the renamed name, except dashes are replaced
                    // with underscores.
                    let resolved_name = rename.replace('-', "_");
                    let (_, deps) = renamed_map
                        .entry(resolved_name.into())
                        .or_insert_with(|| (rename.as_str(), DependencyReqs::default()));
                    deps.push(dep);
                }
                Some(_) | None => {
                    let deps = original_map.entry(dep.name.as_str()).or_default();
                    deps.push(dep);
                }
            }
        }

        Self {
            from_id,
            package_data,
            renamed_map,
            original_map,
        }
    }
/// Constructs a new resolver using the provided package data and dependencies.
Constructs a new resolver using the provided package data and dependencies.
Constructs a new resolver using the provided package data and dependencies .
fn new(
        from_id: &'g PackageId,
        package_data: &'g HashMap<PackageId, (NodeIndex<PackageIx>, String, Version)>,
        package_deps: impl IntoIterator<Item = &'g Dependency>,
    ) -> Self {
        let mut renamed_map = HashMap::new();
        let mut original_map: HashMap<_, DependencyReqs<'g>> = HashMap::new();
        for dep in package_deps {
            match &dep.rename {
                // The rename != dep.name check is because of Cargo.toml instances like this:
                //
                // [dependencies]
                // datatest = "0.4.2"
                //
                // [build-dependencies]
                // datatest = { package = "datatest", version = "0.4.2" }
                //
                // cargo seems to accept such cases if the name doesn't contain a hyphen.
                Some(rename) if rename != &dep.name => {
                    // The resolved name is the same as the renamed name, except dashes are replaced
                    // with underscores.
                    let resolved_name = rename.replace('-', "_");
                    let (_, deps) = renamed_map
                        .entry(resolved_name.into())
                        .or_insert_with(|| (rename.as_str(), DependencyReqs::default()));
                    deps.push(dep);
                }
                Some(_) | None => {
                    let deps = original_map.entry(dep.name.as_str()).or_default();
                    deps.push(dep);
                }
            }
        }
        Self {
            from_id,
            package_data,
            renamed_map,
            original_map,
        }
    }
fn new ( from_id : & ' g PackageId , package_data : & ' g HashMap < PackageId , ( NodeIndex < PackageIx > , String , Version ) > , package_deps : impl IntoIterator < Item = & ' g Dependency > , ) -> Self { let mut renamed_map = HashMap :: new ( ) ; let mut original_map : HashMap < _ , DependencyReqs < ' g > > = HashMap :: new ( ) ; for dep in package_deps { match & dep . rename { // The rename != dep.name check is because of Cargo.toml instances like this: // // [dependencies] // datatest = "0.4.2" // // [build-dependencies] // datatest = { package = "datatest", version = "0.4.2" } // // cargo seems to accept such cases if the name doesn't contain a hyphen. Some ( rename ) if rename != & dep . name => { // The resolved name is the same as the renamed name, except dashes are replaced // with underscores. let resolved_name = rename . replace ( '-' , " " ) ; let ( _ , deps ) = renamed_map . entry ( resolved_name . into ( ) ) . or_insert_with ( | | ( rename . as_str ( ) , DependencyReqs :: default ( ) ) ) ; deps . push ( dep ) ; } Some ( _ ) | None => { let deps = original_map . entry ( dep . name . as_str ( ) ) . or_default ( ) ; deps . push ( dep ) ; } } } Self { from_id , package_data , renamed_map , original_map , } }
Constructs a new resolver using the provided package data and dependencies.
Constructs a new resolver using the provided package data and dependencies .
from_id
&'g PackageId
package_data
&'g HashMap<PackageId, (NodeIndex<PackageIx>, String, Version)>
package_deps
impl IntoIterator<Item = &'g Dependency>
from_id
&'g PackageId
package_data
&'g HashMap<PackageId, (NodeIndex<PackageIx>, String, Version)>
package_deps
impl IntoIterator<Item = &'g Dependency>