Skip to content

Commit

Permalink
refactor(toml): Be consistent in duplicate field access
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 10, 2023
1 parent f520d6c commit 86a11ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,7 @@ impl schema::TomlManifest {
package_root: &Path,
) -> CargoResult<schema::TomlManifest> {
let config = ws.config();
let mut package = self
.package
.as_ref()
.or_else(|| self.project.as_ref())
.unwrap()
.clone();
let mut package = self.package().unwrap().clone();
package.workspace = None;
let current_resolver = package
.resolver
Expand Down
5 changes: 5 additions & 0 deletions src/cargo/util/toml/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//!
//! ## Style
//!
//! - Fields duplicated for an alias will have an accessor with the primary field's name
//! - Keys that exist for bookkeeping but don't correspond to the schema have a `_` prefix

use std::collections::BTreeMap;
Expand Down Expand Up @@ -51,6 +52,10 @@ impl TomlManifest {
self.profile.is_some()
}

pub fn package(&self) -> Option<&Box<TomlPackage>> {
self.package.as_ref().or(self.project.as_ref())
}

pub fn dev_dependencies(&self) -> Option<&BTreeMap<String, MaybeWorkspaceDependency>> {
self.dev_dependencies
.as_ref()
Expand Down

0 comments on commit 86a11ba

Please sign in to comment.