Skip to content

Commit

Permalink
Format with rustfmt 2018-12-10
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 3, 2019
1 parent 6a3a820 commit c473633
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
9 changes: 3 additions & 6 deletions serde_derive/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,7 @@ fn serialize_struct(params: &Parameters, fields: &[Field], cattrs: &attr::Contai
}
}

fn serialize_struct_tag_field(
cattrs: &attr::Container,
struct_trait: &StructTrait,
) -> TokenStream {
fn serialize_struct_tag_field(cattrs: &attr::Container, struct_trait: &StructTrait) -> TokenStream {
match *cattrs.tag() {
attr::TagType::Internal { ref tag } => {
let type_name = cattrs.name().serialize_name();
Expand All @@ -301,7 +298,7 @@ fn serialize_struct_tag_field(
try!(#func(&mut __serde_state, #tag, #type_name));
}
}
_ => quote!{}
_ => quote! {},
}
}

Expand Down Expand Up @@ -377,7 +374,7 @@ fn serialize_struct_as_map(
})
.fold(
quote!(#tag_field_exists as usize),
|sum, expr| quote!(#sum + #expr)
|sum, expr| quote!(#sum + #expr),
);
quote!(_serde::export::Some(#len))
};
Expand Down
18 changes: 9 additions & 9 deletions test_suite/tests/test_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,20 +1427,20 @@ fn test_internally_tagged_braced_struct_with_zero_fields() {
#[test]
fn test_internally_tagged_struct_with_flattened_field() {
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag="tag_struct")]
#[serde(tag = "tag_struct")]
pub struct Struct {
#[serde(flatten)]
pub flat: Enum
pub flat: Enum,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag="tag_enum", content="content")]
#[serde(tag = "tag_enum", content = "content")]
pub enum Enum {
A(u64),
}

assert_tokens(
&Struct{flat: Enum::A(0)},
&Struct { flat: Enum::A(0) },
&[
Token::Map { len: None },
Token::Str("tag_struct"),
Expand All @@ -1449,20 +1449,20 @@ fn test_internally_tagged_struct_with_flattened_field() {
Token::Str("A"),
Token::Str("content"),
Token::U64(0),
Token::MapEnd
]
Token::MapEnd,
],
);

assert_de_tokens(
&Struct{flat: Enum::A(0)},
&Struct { flat: Enum::A(0) },
&[
Token::Map { len: None },
Token::Str("tag_enum"),
Token::Str("A"),
Token::Str("content"),
Token::U64(0),
Token::MapEnd
]
Token::MapEnd,
],
);
}

Expand Down

0 comments on commit c473633

Please sign in to comment.