fn new()

in guppy/src/graph/summaries/package_set.rs [579:621]


    fn new(
        summary: &'a PackageSetSummary,
        mut registry_name_to_url: impl FnMut(&str) -> Option<&'a str>,
        error_message: &str,
    ) -> Result<Self, Error> {
        let summary_ids = summary
            .summary_ids
            .iter()
            .map(|summary_id| (summary_id, false))
            .collect();

        let mut third_party: HashMap<_, SmallVec<[_; 2]>> = HashMap::new();
        let mut registry_names_to_urls = HashMap::new();
        for tp_summary in &summary.third_party {
            if let ThirdPartySource::Registry(Some(name)) = &tp_summary.source {
                if !registry_names_to_urls.contains_key(name.as_str()) {
                    match registry_name_to_url(name) {
                        Some(url) => {
                            registry_names_to_urls.insert(name.as_str(), url);
                        }
                        None => {
                            return Err(Error::UnknownRegistryName {
                                message: error_message.to_owned(),
                                summary: tp_summary.clone(),
                                registry_name: name.clone(),
                            });
                        }
                    }
                }
            }
            third_party
                .entry(tp_summary.name.as_str())
                .or_default()
                .push((tp_summary, false));
        }

        Ok(Self {
            summary_ids,
            workspace_members: &summary.workspace_members,
            third_party,
            registry_names_to_urls,
        })
    }