From 1a20200e09ef7ac5a394509ac02b0167ea11ab12 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 13 Sep 2022 11:17:29 -0500 Subject: [PATCH] chore: Document new add implementation --- src/cargo/ops/cargo_add/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cargo/ops/cargo_add/mod.rs b/src/cargo/ops/cargo_add/mod.rs index 4cdc5c621c3..b6491f59dbb 100644 --- a/src/cargo/ops/cargo_add/mod.rs +++ b/src/cargo/ops/cargo_add/mod.rs @@ -599,9 +599,14 @@ fn populate_dependency(mut dependency: Dependency, arg: &DepOp) -> Dependency { dependency } +/// Track presentation-layer information with the editable representation of a `[dependencies]` +/// entry (Dependency) pub struct DependencyUI { + /// Editable representation of a `[depednencies]` entry dep: Dependency, + /// The version of the crate that we pulled `available_features` from available_version: Option, + /// The widest set of features compatible with `Dependency`s version requirement available_features: BTreeMap>, } @@ -772,6 +777,8 @@ fn print_msg(shell: &mut Shell, dep: &DependencyUI, section: &[String]) -> Cargo let mut version = version.clone(); version.build = Default::default(); let version = version.to_string(); + // Avoid displaying the version if it will visually look like the version req that we + // showed earlier let version_req = dep .version() .and_then(|v| semver::VersionReq::parse(v).ok()) @@ -844,6 +851,8 @@ fn find_workspace_dep(toml_key: &str, root_manifest: &Path) -> CargoResult Option { version_req .comparators