Skip to content

Commit 262d4dd

Browse files
committed
Use Not::not rather than a custom is_false function
The `is_false` function already exists in the standard library, as `Not::not`; use that in `skip_serializing_if` rather than defining an `is_false` function.
1 parent fc1518e commit 262d4dd

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ impl TomlPlatform {
14961496
#[derive(Serialize, Debug, Clone)]
14971497
#[cfg_attr(feature = "unstable-schema", derive(schemars::JsonSchema))]
14981498
pub struct InheritableLints {
1499-
#[serde(skip_serializing_if = "is_false")]
1499+
#[serde(skip_serializing_if = "std::ops::Not::not")]
15001500
#[cfg_attr(feature = "unstable-schema", schemars(default))]
15011501
pub workspace: bool,
15021502
#[serde(flatten)]
@@ -1513,10 +1513,6 @@ impl InheritableLints {
15131513
}
15141514
}
15151515

1516-
fn is_false(b: &bool) -> bool {
1517-
!b
1518-
}
1519-
15201516
impl<'de> Deserialize<'de> for InheritableLints {
15211517
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
15221518
where

crates/crates-io/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,10 @@ pub struct NewCrateDependency {
8282
pub artifact: Option<Vec<String>>,
8383
#[serde(skip_serializing_if = "Option::is_none")]
8484
pub bindep_target: Option<String>,
85-
#[serde(default, skip_serializing_if = "is_false")]
85+
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
8686
pub lib: bool,
8787
}
8888

89-
fn is_false(x: &bool) -> bool {
90-
*x == false
91-
}
92-
9389
#[derive(Deserialize)]
9490
pub struct User {
9591
pub id: u32,

0 commit comments

Comments
 (0)