From b2b01cab847c7d329484a4f4ee314b25f97d010b Mon Sep 17 00:00:00 2001 From: Kornel Date: Tue, 3 Sep 2024 18:16:09 +0100 Subject: [PATCH] Allow fields to be omitted in registry index summaries --- src/cargo/sources/registry/index/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cargo/sources/registry/index/mod.rs b/src/cargo/sources/registry/index/mod.rs index e0fd92c279c..6878c59670a 100644 --- a/src/cargo/sources/registry/index/mod.rs +++ b/src/cargo/sources/registry/index/mod.rs @@ -206,6 +206,7 @@ pub struct IndexPackage<'a> { #[serde(borrow)] pub deps: Vec>, /// Set of features defined for the package, i.e., `[features]` table. + #[serde(default)] pub features: BTreeMap>, /// This field contains features with new, extended syntax. Specifically, /// namespaced features (`dep:`) and weak dependencies (`pkg?/feat`). @@ -268,10 +269,13 @@ pub struct RegistryDependency<'a> { #[serde(borrow)] pub req: Cow<'a, str>, /// Set of features enabled for this dependency. + #[serde(default)] pub features: Vec, /// Whether or not this is an optional dependency. + #[serde(default)] pub optional: bool, /// Whether or not default features are enabled. + #[serde(default = "default_true")] pub default_features: bool, /// The target platform for this dependency. pub target: Option>, @@ -292,6 +296,10 @@ pub struct RegistryDependency<'a> { pub lib: bool, } +fn default_true() -> bool { + true +} + impl<'gctx> RegistryIndex<'gctx> { /// Creates an empty registry index at `path`. pub fn new(