]> git.proxmox.com Git - cargo.git/commitdiff
refactor(add): Make it easier to add more summary info
authorEd Page <eopage@gmail.com>
Mon, 12 Sep 2022 14:26:14 +0000 (09:26 -0500)
committerEd Page <eopage@gmail.com>
Mon, 12 Sep 2022 14:26:14 +0000 (09:26 -0500)
src/cargo/ops/cargo_add/mod.rs

index cc54b7a8877964809dfc1a9d7f0e7e806dce7ae5..08695525be171980d429a76ff2cb0916c9da6fa7 100644 (file)
@@ -19,7 +19,6 @@ use toml_edit::Item as TomlItem;
 
 use crate::core::dependency::DepKind;
 use crate::core::registry::PackageRegistry;
-use crate::core::FeatureMap;
 use crate::core::FeatureValue;
 use crate::core::Package;
 use crate::core::QueryKind;
@@ -613,8 +612,9 @@ impl DependencyEx {
         }
     }
 
-    fn set_available_features(&mut self, available_features: &FeatureMap) {
-        self.available_features = available_features
+    fn apply_summary(&mut self, summary: &Summary) {
+        self.available_features = summary
+            .features()
             .iter()
             .map(|(k, v)| {
                 (
@@ -635,7 +635,7 @@ impl<'s> From<&'s Summary> for DependencyEx {
     fn from(other: &'s Summary) -> Self {
         let dep = Dependency::from(other);
         let mut dep = Self::new(dep);
-        dep.set_available_features(other.features());
+        dep.apply_summary(other);
         dep
     }
 }
@@ -687,7 +687,7 @@ fn populate_available_features(
         .ok_or_else(|| {
             anyhow::format_err!("the crate `{dependency}` could not be found in registry index.")
         })?;
-    dependency.set_available_features(lowest_common_denominator.features());
+    dependency.apply_summary(&lowest_common_denominator);
 
     Ok(dependency)
 }