Skip to content

Commit

Permalink
Auto merge of #14271 - Alexendoo:schemas, r=epage
Browse files Browse the repository at this point in the history
Add `TomlPackage::new`, `Default` for `TomlWorkspace`

Ran into this when using it to create a `Cargo.toml` rather than consume an existing one
  • Loading branch information
bors committed Jul 19, 2024
2 parents 4196ea0 + 9f85086 commit 5f6b9a9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/cargo-util-schemas/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-util-schemas"
version = "0.5.0"
version = "0.5.1"
rust-version = "1.79" # MSRV:1
edition.workspace = true
license.workspace = true
Expand Down
40 changes: 39 additions & 1 deletion crates/cargo-util-schemas/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl TomlManifest {
}
}

#[derive(Debug, Deserialize, Serialize, Clone)]
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct TomlWorkspace {
pub members: Option<Vec<String>>,
Expand Down Expand Up @@ -199,6 +199,44 @@ pub struct TomlPackage {
}

impl TomlPackage {
pub fn new(name: PackageName) -> Self {
Self {
name,

edition: None,
rust_version: None,
version: None,
authors: None,
build: None,
metabuild: None,
default_target: None,
forced_target: None,
links: None,
exclude: None,
include: None,
publish: None,
workspace: None,
im_a_teapot: None,
autobins: None,
autoexamples: None,
autotests: None,
autobenches: None,
default_run: None,
description: None,
homepage: None,
documentation: None,
readme: None,
keywords: None,
categories: None,
license: None,
license_file: None,
repository: None,
resolver: None,
metadata: None,
_invalid_cargo_features: None,
}
}

pub fn resolved_edition(&self) -> Result<Option<&String>, UnresolvedError> {
self.edition.as_ref().map(|v| v.resolved()).transpose()
}
Expand Down

0 comments on commit 5f6b9a9

Please sign in to comment.