]> git.proxmox.com Git - cargo.git/commitdiff
refactor(add): Consolidate looking up available features
authorEd Page <eopage@gmail.com>
Mon, 12 Sep 2022 14:18:15 +0000 (09:18 -0500)
committerEd Page <eopage@gmail.com>
Mon, 12 Sep 2022 14:18:17 +0000 (09:18 -0500)
This optimization doesn't really make a difference and it makes it
harder to separate UI / edit concerns.

src/cargo/ops/cargo_add/dependency.rs
src/cargo/ops/cargo_add/mod.rs

index e86f12e033c141c2d1769862873684b5b8735f85..64691777e450be20d9962794a9521406fe49a2fb 100644 (file)
@@ -85,15 +85,6 @@ impl Dependency {
         self
     }
 
-    /// Set the available features of the dependency to a given vec
-    pub fn set_available_features(
-        mut self,
-        available_features: BTreeMap<String, Vec<String>>,
-    ) -> Self {
-        self.available_features = available_features;
-        self
-    }
-
     /// Populate from cargo
     pub fn set_available_features_from_cargo(
         mut self,
index ede28c7e86d3734073f967960c544d1d71c2c365..57df8c6d8f6392417b8788ba153b80b127787670 100644 (file)
@@ -284,9 +284,7 @@ fn resolve_dependency(
                 // Overwrite with `crate_spec`
                 old_dep.source = selected_dep.source;
             }
-            old_dep = populate_dependency(old_dep, arg);
-            old_dep.available_features = selected_dep.available_features;
-            old_dep
+            populate_dependency(old_dep, arg)
         }
     } else {
         selected_dep
@@ -318,9 +316,7 @@ fn resolve_dependency(
                 ))?;
                 dependency.name = latest.name; // Normalize the name
             }
-            dependency = dependency
-                .set_source(latest.source.expect("latest always has a source"))
-                .set_available_features(latest.available_features);
+            dependency = dependency.set_source(latest.source.expect("latest always has a source"));
         }
     }