Skip to content

Commit

Permalink
Add TomlPackage::new, Default for TomlWorkspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexendoo committed Jul 19, 2024
1 parent dad331c commit 9f85086
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 9f85086

Please sign in to comment.