Skip to content

Commit 3efc7de

Browse files
committed
Flatten one layer in the serde impl
1 parent faa9644 commit 3efc7de

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/datetime/src/provider/packed_pattern.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct LengthPluralElements<T> {
3838
pub struct PackedPatternsBuilder<'a> {
3939
/// Patterns always available.
4040
#[cfg_attr(feature = "serde", serde(borrow))]
41+
#[cfg_attr(feature = "serde", serde(flatten))]
4142
pub standard: LengthPluralElements<Pattern<'a>>,
4243
/// Patterns for variant 0. If `None`, falls back to standard.
4344
#[cfg_attr(feature = "serde", serde(borrow))]
@@ -606,7 +607,7 @@ pub mod tests {
606607
assert_eq!(builder, bincode_recovered.to_builder());
607608

608609
let json_str = serde_json::to_string(&packed).unwrap();
609-
assert_eq!(json_str, "{\"standard\":{\"long\":{\"other\":\"M/d/y\"},\"medium\":{\"other\":\"M/d/y\"},\"short\":{\"other\":\"HH:mm\"}},\"variant0\":{\"long\":{\"other\":\"E\"},\"medium\":{\"other\":\"E MMM d\"},\"short\":{\"other\":\"dd.MM.yy\"}}}");
610+
assert_eq!(json_str, "{\"long\":{\"other\":\"M/d/y\"},\"medium\":{\"other\":\"M/d/y\"},\"short\":{\"other\":\"HH:mm\"},\"variant0\":{\"long\":{\"other\":\"E\"},\"medium\":{\"other\":\"E MMM d\"},\"short\":{\"other\":\"dd.MM.yy\"}}}");
610611
let json_recovered = serde_json::from_str::<PackedPatternsV1>(&json_str).unwrap();
611612
assert_eq!(builder, json_recovered.to_builder());
612613
}

0 commit comments

Comments
 (0)