Skip to content

Commit cf2d81f

Browse files
committed
fix: add missing derive macros for CSSInteger
CSSInteger is used as a field type in MediaCondition and ParsedComponent enums, which require serde, jsonschema, visitor, and into_owned derives when their respective features are enabled. This commit adds the necessary conditional derive attributes to fix compilation errors when running `cargo test --all-features`.
1 parent 31ea74e commit cf2d81f

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/properties/align.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::prefixes::{is_flex_2009, Feature};
1111
use crate::printer::Printer;
1212
use crate::traits::{FromStandard, Parse, PropertyHandler, Shorthand, ToCss};
1313
use crate::values::length::LengthPercentage;
14-
use crate::values::number::CSSInteger;
1514
use crate::vendor_prefix::VendorPrefix;
1615
#[cfg(feature = "visitor")]
1716
use crate::visitor::Visit;

src/values/number.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use crate::error::{ParserError, PrinterError};
66
use crate::printer::Printer;
77
use crate::traits::private::AddInternal;
88
use crate::traits::{Map, Op, Parse, Sign, ToCss, Zero};
9+
#[cfg(feature = "visitor")]
10+
use crate::visitor::Visit;
911
use cssparser::*;
1012

1113
/// A CSS [`<number>`](https://www.w3.org/TR/css-values-4/#numbers) value.
@@ -127,6 +129,10 @@ impl_try_from_angle!(CSSNumber);
127129
/// Integers may be explicit or computed by `calc()`, but are always stored and serialized
128130
/// as their computed value.
129131
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
132+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize), serde(transparent))]
133+
#[cfg_attr(feature = "jsonschema", derive(schemars::JsonSchema))]
134+
#[cfg_attr(feature = "visitor", derive(crate::visitor::Visit))]
135+
#[cfg_attr(feature = "into_owned", derive(static_self::IntoOwned))]
130136
pub struct CSSInteger(pub i32);
131137

132138
impl std::ops::Deref for CSSInteger {

0 commit comments

Comments
 (0)