mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Use Not::not
rather than a custom is_false
function (#15645)
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:
commit
aed94a893c
@ -1496,7 +1496,7 @@ impl TomlPlatform {
|
|||||||
#[derive(Serialize, Debug, Clone)]
|
#[derive(Serialize, Debug, Clone)]
|
||||||
#[cfg_attr(feature = "unstable-schema", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "unstable-schema", derive(schemars::JsonSchema))]
|
||||||
pub struct InheritableLints {
|
pub struct InheritableLints {
|
||||||
#[serde(skip_serializing_if = "is_false")]
|
#[serde(skip_serializing_if = "std::ops::Not::not")]
|
||||||
#[cfg_attr(feature = "unstable-schema", schemars(default))]
|
#[cfg_attr(feature = "unstable-schema", schemars(default))]
|
||||||
pub workspace: bool,
|
pub workspace: bool,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
@ -1513,10 +1513,6 @@ impl InheritableLints {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_false(b: &bool) -> bool {
|
|
||||||
!b
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for InheritableLints {
|
impl<'de> Deserialize<'de> for InheritableLints {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
|
@ -82,14 +82,10 @@ pub struct NewCrateDependency {
|
|||||||
pub artifact: Option<Vec<String>>,
|
pub artifact: Option<Vec<String>>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub bindep_target: Option<String>,
|
pub bindep_target: Option<String>,
|
||||||
#[serde(default, skip_serializing_if = "is_false")]
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||||
pub lib: bool,
|
pub lib: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_false(x: &bool) -> bool {
|
|
||||||
*x == false
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user