Skip to content

Commit

Permalink
Skip serializing hidden attribute if false
Browse files Browse the repository at this point in the history
  • Loading branch information
madig authored and cmyr committed Aug 24, 2023
1 parent d56c45a commit ca101fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/designspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ pub struct Axis {
#[serde(rename = "@default")]
pub default: f32,
/// Records whether this axis needs to be hidden in interfaces.
#[serde(default)]
#[serde(rename = "@hidden")]
#[serde(default, rename = "@hidden", skip_serializing_if = "is_false")]
pub hidden: bool,
/// The minimum value for a continuous axis, in user space coordinates.
#[serde(rename = "@minimum", skip_serializing_if = "Option::is_none")]
Expand All @@ -70,6 +69,10 @@ pub struct Axis {
pub map: Option<Vec<AxisMapping>>,
}

fn is_false(value: &bool) -> bool {
!(*value)
}

/// Maps one input value (user space coord) to one output value (design space coord).
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
#[serde(rename = "map")]
Expand Down

0 comments on commit ca101fe

Please sign in to comment.