Skip to content

Commit 5f6b9a9

Browse files
committed
Auto merge of #14271 - Alexendoo:schemas, r=epage
Add `TomlPackage::new`, `Default` for `TomlWorkspace` Ran into this when using it to create a `Cargo.toml` rather than consume an existing one
2 parents 4196ea0 + 9f85086 commit 5f6b9a9

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cargo-util-schemas/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-util-schemas"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
rust-version = "1.79" # MSRV:1
55
edition.workspace = true
66
license.workspace = true

crates/cargo-util-schemas/src/manifest/mod.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl TomlManifest {
111111
}
112112
}
113113

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

201201
impl TomlPackage {
202+
pub fn new(name: PackageName) -> Self {
203+
Self {
204+
name,
205+
206+
edition: None,
207+
rust_version: None,
208+
version: None,
209+
authors: None,
210+
build: None,
211+
metabuild: None,
212+
default_target: None,
213+
forced_target: None,
214+
links: None,
215+
exclude: None,
216+
include: None,
217+
publish: None,
218+
workspace: None,
219+
im_a_teapot: None,
220+
autobins: None,
221+
autoexamples: None,
222+
autotests: None,
223+
autobenches: None,
224+
default_run: None,
225+
description: None,
226+
homepage: None,
227+
documentation: None,
228+
readme: None,
229+
keywords: None,
230+
categories: None,
231+
license: None,
232+
license_file: None,
233+
repository: None,
234+
resolver: None,
235+
metadata: None,
236+
_invalid_cargo_features: None,
237+
}
238+
}
239+
202240
pub fn resolved_edition(&self) -> Result<Option<&String>, UnresolvedError> {
203241
self.edition.as_ref().map(|v| v.resolved()).transpose()
204242
}

0 commit comments

Comments
 (0)