fn new()

in tools/hakari/src/explain/mod.rs [157:212]


    fn new(hakari: &'a Hakari<'g>, dep_id: &'g PackageId) -> Result<Self, guppy::Error> {
        let mut target_map: IntermediateMap<'g, 'a> = BTreeMap::new();
        let mut host_map: IntermediateMap<'g, 'a> = BTreeMap::new();

        // Look at the computed map to figure out which packages are built.
        let platform_idxs =
            std::iter::once(None).chain((0..=hakari.builder.platforms.len()).map(Some));
        let map_keys = platform_idxs.map(|idx| (idx, dep_id));

        for (platform, package_id) in map_keys {
            let computed_value = match hakari.computed_map.get(&(platform, package_id)) {
                Some(v) => v,
                None => continue,
            };

            for (build_platform, inner_map) in computed_value.inner_maps() {
                let map = match build_platform {
                    BuildPlatform::Target => &mut target_map,
                    BuildPlatform::Host => &mut host_map,
                };

                for (features, inner_value) in inner_map {
                    for &(workspace_package, standard_features, include_dev) in
                        &inner_value.workspace_packages
                    {
                        map.entry(features)
                            .or_default()
                            .workspace_packages
                            .entry(workspace_package.id())
                            .or_insert_with(|| IntermediateInnerValue {
                                metadata: workspace_package,
                                sets: BTreeSet::new(),
                            })
                            .sets
                            .insert((include_dev, standard_features, platform));
                    }

                    if inner_value.fixed_up {
                        map.entry(features)
                            .or_default()
                            .fixup_platforms
                            .insert(platform);
                    }
                }
            }
        }

        if target_map.is_empty() && host_map.is_empty() {
            return Err(guppy::Error::UnknownPackageId(dep_id.clone()));
        }

        Ok(Self {
            target_map,
            host_map,
        })
    }