Skip to content

Commit

Permalink
fix custom_values type
Browse files Browse the repository at this point in the history
  • Loading branch information
yg0x01 committed Feb 9, 2025
1 parent 394265f commit 0b7122f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions charming/src/element/axis_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub struct AxisLabel {
#[serde(skip_serializing_if = "Option::is_none")]
interval: Option<f64>,

#[serde(skip_serializing_if = "Option::is_none")]
custom_values: Option<Vec<CompositeValue>>,
#[serde(skip_serializing_if = "Vec::is_empty")]
custom_values: Vec<CompositeValue>,
}

impl Default for AxisLabel {
Expand All @@ -64,7 +64,7 @@ impl AxisLabel {
formatter: None,
rotate: None,
interval: None,
custom_values: None,
custom_values: vec![],
}
}

Expand Down Expand Up @@ -118,8 +118,8 @@ impl AxisLabel {
self
}

pub fn custom_values(mut self, custom_values: Vec<CompositeValue>) -> Self {
self.custom_values = Some(custom_values);
pub fn custom_values<C: Into<CompositeValue>>(mut self, custom_value: C) -> Self {
self.custom_values.push(custom_value.into());
self
}
}
10 changes: 5 additions & 5 deletions charming/src/element/axis_tick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub struct AxisTick {
#[serde(skip_serializing_if = "Option::is_none")]
line_style: Option<LineStyle>,

#[serde(skip_serializing_if = "Option::is_none")]
custom_values: Option<Vec<CompositeValue>>,
#[serde(skip_serializing_if = "Vec::is_empty")]
custom_values: Vec<CompositeValue>,
}

impl Default for AxisTick {
Expand All @@ -40,7 +40,7 @@ impl AxisTick {
length: None,
distance: None,
line_style: None,
custom_values: None,
custom_values: vec![],
}
}

Expand Down Expand Up @@ -69,8 +69,8 @@ impl AxisTick {
self
}

pub fn custom_values(mut self, custom_values: Vec<CompositeValue>) -> Self {
self.custom_values = Some(custom_values);
pub fn custom_values<C: Into<CompositeValue>>(mut self, custom_value: C) -> Self {
self.custom_values.push(custom_value.into());
self
}
}

0 comments on commit 0b7122f

Please sign in to comment.