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.
This commit is contained in:
Josh Triplett 2025-06-08 19:15:27 -07:00
parent fc1518ef02
commit 262d4dd5f2
2 changed files with 2 additions and 10 deletions

View File

@ -1496,7 +1496,7 @@ impl TomlPlatform {
#[derive(Serialize, Debug, Clone)]
#[cfg_attr(feature = "unstable-schema", derive(schemars::JsonSchema))]
pub struct InheritableLints {
#[serde(skip_serializing_if = "is_false")]
#[serde(skip_serializing_if = "std::ops::Not::not")]
#[cfg_attr(feature = "unstable-schema", schemars(default))]
pub workspace: bool,
#[serde(flatten)]
@ -1513,10 +1513,6 @@ impl InheritableLints {
}
}
fn is_false(b: &bool) -> bool {
!b
}
impl<'de> Deserialize<'de> for InheritableLints {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where

View File

@ -82,14 +82,10 @@ pub struct NewCrateDependency {
pub artifact: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bindep_target: Option<String>,
#[serde(default, skip_serializing_if = "is_false")]
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub lib: bool,
}
fn is_false(x: &bool) -> bool {
*x == false
}
#[derive(Deserialize)]
pub struct User {
pub id: u32,