Skip to content

Commit 1a20200

Browse files
committed
chore: Document new add implementation
1 parent f1548f6 commit 1a20200

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cargo/ops/cargo_add/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,14 @@ fn populate_dependency(mut dependency: Dependency, arg: &DepOp) -> Dependency {
599599
dependency
600600
}
601601

602+
/// Track presentation-layer information with the editable representation of a `[dependencies]`
603+
/// entry (Dependency)
602604
pub struct DependencyUI {
605+
/// Editable representation of a `[depednencies]` entry
603606
dep: Dependency,
607+
/// The version of the crate that we pulled `available_features` from
604608
available_version: Option<semver::Version>,
609+
/// The widest set of features compatible with `Dependency`s version requirement
605610
available_features: BTreeMap<String, Vec<String>>,
606611
}
607612

@@ -772,6 +777,8 @@ fn print_msg(shell: &mut Shell, dep: &DependencyUI, section: &[String]) -> Cargo
772777
let mut version = version.clone();
773778
version.build = Default::default();
774779
let version = version.to_string();
780+
// Avoid displaying the version if it will visually look like the version req that we
781+
// showed earlier
775782
let version_req = dep
776783
.version()
777784
.and_then(|v| semver::VersionReq::parse(v).ok())
@@ -844,6 +851,8 @@ fn find_workspace_dep(toml_key: &str, root_manifest: &Path) -> CargoResult<Depen
844851
Dependency::from_toml(root_manifest.parent().unwrap(), toml_key, dep_item)
845852
}
846853

854+
/// Convert a `semver::VersionReq` into a rendered `semver::Version` if all fields are fully
855+
/// specified.
847856
fn precise_version(version_req: &semver::VersionReq) -> Option<String> {
848857
version_req
849858
.comparators

0 commit comments

Comments
 (0)