Skip to content

Commit 86a11ba

Browse files
committed
refactor(toml): Be consistent in duplicate field access
1 parent f520d6c commit 86a11ba

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/cargo/util/toml/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,7 @@ impl schema::TomlManifest {
194194
package_root: &Path,
195195
) -> CargoResult<schema::TomlManifest> {
196196
let config = ws.config();
197-
let mut package = self
198-
.package
199-
.as_ref()
200-
.or_else(|| self.project.as_ref())
201-
.unwrap()
202-
.clone();
197+
let mut package = self.package().unwrap().clone();
203198
package.workspace = None;
204199
let current_resolver = package
205200
.resolver

src/cargo/util/toml/schema.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//!
33
//! ## Style
44
//!
5+
//! - Fields duplicated for an alias will have an accessor with the primary field's name
56
//! - Keys that exist for bookkeeping but don't correspond to the schema have a `_` prefix
67
78
use std::collections::BTreeMap;
@@ -51,6 +52,10 @@ impl TomlManifest {
5152
self.profile.is_some()
5253
}
5354

55+
pub fn package(&self) -> Option<&Box<TomlPackage>> {
56+
self.package.as_ref().or(self.project.as_ref())
57+
}
58+
5459
pub fn dev_dependencies(&self) -> Option<&BTreeMap<String, MaybeWorkspaceDependency>> {
5560
self.dev_dependencies
5661
.as_ref()

0 commit comments

Comments
 (0)