Skip to content

Commit

Permalink
Flatten one layer in the serde impl
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Sep 24, 2024
1 parent 93e9b96 commit c7a4f6b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/datetime/src/provider/packed_pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct LengthPluralElements<T> {
pub struct PackedPatternsBuilder<'a> {
/// Patterns always available.
#[cfg_attr(feature = "serde", serde(borrow))]
#[cfg_attr(feature = "serde", serde(flatten))]
pub standard: LengthPluralElements<Pattern<'a>>,
/// Patterns for variant 0. If `None`, falls back to standard.
#[cfg_attr(feature = "serde", serde(borrow))]
Expand Down Expand Up @@ -582,7 +583,7 @@ pub mod tests {
assert_eq!(builder, bincode_recovered.to_builder());

let json_str = serde_json::to_string(&packed).unwrap();
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\"}}}");
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\"}}}");
let json_recovered = serde_json::from_str::<PackedPatternsV1>(&json_str).unwrap();
assert_eq!(builder, json_recovered.to_builder());
}
Expand Down

0 comments on commit c7a4f6b

Please sign in to comment.