Skip to content

Commit 00d98b6

Browse files
committed
Fix serde feature with Units trait
Signed-off-by: Nico Burns <nico@nicoburns.com>
1 parent d4e0753 commit 00d98b6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/style/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ impl<T> Calc for T where T: Clone + Debug + 'static {}
6868
pub trait Units {
6969
/// Trait that represents a cheaply clonable string. If you're unsure what to use here
7070
/// consider `Arc<str>` or `string_cache::Atom`.
71+
#[cfg(not(feature = "serde"))]
7172
type Str: CheapCloneStr;
73+
/// Trait that represents a cheaply clonable string. If you're unsure what to use here
74+
/// consider `Arc<str>` or `string_cache::Atom`.
75+
#[cfg(feature = "serde")]
76+
type Str: CheapCloneStr + serde::Serialize + for<'a> serde::Deserialize<'a>;
7277

7378
/// Type representing a calc expression.
7479
/// If you're not using Calc then you can just use `()`

tests/serde.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#[cfg(feature = "serde")]
33
mod serde {
44
use serde_json::{self, Value};
5-
use taffy::style::Style;
5+
use taffy::{DefaultUnits, Style};
66

77
#[test]
88
fn serde_can_serialize() {
9-
let style: Style<String> = Style::DEFAULT;
9+
let style: Style<DefaultUnits> = Style::DEFAULT;
1010
let _ = serde_json::to_string(&style).unwrap();
1111
}
1212

0 commit comments

Comments
 (0)