diff --git a/src/style/mod.rs b/src/style/mod.rs
index 4be7baf89..b0ac5dc84 100644
--- a/src/style/mod.rs
+++ b/src/style/mod.rs
@@ -72,7 +72,12 @@ impl<T> Calc for T where T: Clone + Debug + 'static {}
pub trait Units {
/// Trait that represents a cheaply clonable string. If you're unsure what to use here
/// consider `Arc<str>` or `string_cache::Atom`.
+ #[cfg(not(feature = "serde"))]
type Str: CheapCloneStr;
+ /// Trait that represents a cheaply clonable string. If you're unsure what to use here
+ /// consider `Arc<str>` or `string_cache::Atom`.
+ #[cfg(feature = "serde")]
+ type Str: CheapCloneStr + serde::Serialize + for<'a> serde::Deserialize<'a>;
/// Type representing a calc expression.
/// If you're not using Calc then you can just use `()`
diff --git a/tests/serde.rs b/tests/serde.rs
index 0ddce2ba0..f2f9ecf7a 100644
--- a/tests/serde.rs
+++ b/tests/serde.rs
@@ -2,11 +2,11 @@
#[cfg(feature = "serde")]
mod serde {
use serde_json::{self, Value};
- use taffy::style::Style;
+ use taffy::{DefaultUnits, Style};
#[test]
fn serde_can_serialize() {
- let style: Style<String> = Style::DEFAULT;
+ let style: Style<DefaultUnits> = Style::DEFAULT;
let _ = serde_json::to_string(&style).unwrap();
}