Format with rustfmt 0.7.0
This commit is contained in:
parent
0c5f20c148
commit
4fa2a50f62
@ -1411,7 +1411,8 @@ impl<'de> Visitor<'de> for OsStringVisitor {
|
||||
use std::os::windows::ffi::OsStringExt;
|
||||
|
||||
match try!(data.variant()) {
|
||||
(OsStringKind::Windows, v) => v.newtype_variant::<Vec<u16>>()
|
||||
(OsStringKind::Windows, v) => v
|
||||
.newtype_variant::<Vec<u16>>()
|
||||
.map(|vec| OsString::from_wide(&vec)),
|
||||
(OsStringKind::Unix, _) => Err(Error::custom(
|
||||
"cannot deserialize Unix OS string on Windows",
|
||||
|
@ -2323,7 +2323,8 @@ mod content {
|
||||
T: de::DeserializeSeed<'de>,
|
||||
{
|
||||
match self.iter.next() {
|
||||
Some(value) => seed.deserialize(ContentRefDeserializer::new(value))
|
||||
Some(value) => seed
|
||||
.deserialize(ContentRefDeserializer::new(value))
|
||||
.map(Some),
|
||||
None => Ok(None),
|
||||
}
|
||||
@ -2821,14 +2822,13 @@ where
|
||||
// about. In case we do not know which fields we want, we take them all.
|
||||
let use_item = match *item {
|
||||
None => false,
|
||||
Some((ref c, _)) => {
|
||||
c.as_str()
|
||||
.map_or(self.fields.is_none(), |key| match self.fields {
|
||||
None => true,
|
||||
Some(fields) if fields.contains(&key) => true,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
Some((ref c, _)) => c.as_str().map_or(self.fields.is_none(), |key| {
|
||||
match self.fields {
|
||||
None => true,
|
||||
Some(fields) if fields.contains(&key) => true,
|
||||
_ => false,
|
||||
}
|
||||
}),
|
||||
};
|
||||
|
||||
if use_item {
|
||||
|
@ -947,7 +947,8 @@ mod content {
|
||||
where
|
||||
T: Serialize,
|
||||
{
|
||||
let key = self.key
|
||||
let key = self
|
||||
.key
|
||||
.take()
|
||||
.expect("serialize_value called before serialize_key");
|
||||
let value = try!(value.serialize(ContentSerializer::<E>::new()));
|
||||
|
@ -535,7 +535,8 @@ impl Serialize for SystemTime {
|
||||
S: Serializer,
|
||||
{
|
||||
use super::SerializeStruct;
|
||||
let duration_since_epoch = self.duration_since(UNIX_EPOCH)
|
||||
let duration_since_epoch = self
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("SystemTime must be later than UNIX_EPOCH");
|
||||
let mut state = try!(serializer.serialize_struct("SystemTime", 2));
|
||||
try!(state.serialize_field("secs_since_epoch", &duration_since_epoch.as_secs()));
|
||||
|
@ -55,7 +55,8 @@ pub fn with_where_predicates_from_fields(
|
||||
generics: &syn::Generics,
|
||||
from_field: fn(&attr::Field) -> Option<&[syn::WherePredicate]>,
|
||||
) -> syn::Generics {
|
||||
let predicates = cont.data
|
||||
let predicates = cont
|
||||
.data
|
||||
.all_fields()
|
||||
.flat_map(|field| from_field(&field.attrs))
|
||||
.flat_map(|predicates| predicates.to_vec());
|
||||
@ -284,7 +285,8 @@ fn type_of_item(cont: &Container) -> syn::Type {
|
||||
syn::AngleBracketedGenericArguments {
|
||||
colon2_token: None,
|
||||
lt_token: Default::default(),
|
||||
args: cont.generics
|
||||
args: cont
|
||||
.generics
|
||||
.params
|
||||
.iter()
|
||||
.map(|param| match *param {
|
||||
|
@ -203,7 +203,8 @@ fn build_generics(cont: &Container, borrowed: &BorrowedLifetimes) -> syn::Generi
|
||||
fn needs_deserialize_bound(field: &attr::Field, variant: Option<&attr::Variant>) -> bool {
|
||||
!field.skip_deserializing() && field.deserialize_with().is_none() && field.de_bound().is_none()
|
||||
&& variant.map_or(true, |variant| {
|
||||
!variant.skip_deserializing() && variant.deserialize_with().is_none()
|
||||
!variant.skip_deserializing()
|
||||
&& variant.deserialize_with().is_none()
|
||||
&& variant.de_bound().is_none()
|
||||
})
|
||||
}
|
||||
@ -304,7 +305,8 @@ fn deserialize_in_place_body(cont: &Container, params: &Parameters) -> Option<St
|
||||
assert!(!params.has_getter);
|
||||
|
||||
if cont.attrs.type_from().is_some() || cont.attrs.identifier().is_some()
|
||||
|| cont.data
|
||||
|| cont
|
||||
.data
|
||||
.all_fields()
|
||||
.all(|f| f.attrs.deserialize_with().is_some())
|
||||
{
|
||||
@ -695,7 +697,8 @@ fn deserialize_seq_in_place(
|
||||
};
|
||||
|
||||
let mut index_in_seq = 0usize;
|
||||
let write_values = vars.clone()
|
||||
let write_values = vars
|
||||
.clone()
|
||||
.zip(fields)
|
||||
.enumerate()
|
||||
.map(|(field_index, (_, field))| {
|
||||
@ -2596,7 +2599,8 @@ fn deserialize_map_in_place(
|
||||
let missing_expr = expr_is_missing(field, cattrs);
|
||||
// If missing_expr unconditionally returns an error, don't try
|
||||
// to assign its value to self.place.
|
||||
if field.attrs.default().is_none() && cattrs.default().is_none()
|
||||
if field.attrs.default().is_none()
|
||||
&& cattrs.default().is_none()
|
||||
&& field.attrs.deserialize_with().is_some()
|
||||
{
|
||||
let missing_expr = Stmts(missing_expr);
|
||||
|
@ -1426,7 +1426,9 @@ fn is_primitive_type(ty: &syn::Type, primitive: &str) -> bool {
|
||||
}
|
||||
|
||||
fn is_primitive_path(path: &syn::Path, primitive: &str) -> bool {
|
||||
path.leading_colon.is_none() && path.segments.len() == 1 && path.segments[0].ident == primitive
|
||||
path.leading_colon.is_none()
|
||||
&& path.segments.len() == 1
|
||||
&& path.segments[0].ident == primitive
|
||||
&& path.segments[0].arguments.is_empty()
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,8 @@ fn build_generics(cont: &Container) -> syn::Generics {
|
||||
fn needs_serialize_bound(field: &attr::Field, variant: Option<&attr::Variant>) -> bool {
|
||||
!field.skip_serializing() && field.serialize_with().is_none() && field.ser_bound().is_none()
|
||||
&& variant.map_or(true, |variant| {
|
||||
!variant.skip_serializing() && variant.serialize_with().is_none()
|
||||
!variant.skip_serializing()
|
||||
&& variant.serialize_with().is_none()
|
||||
&& variant.ser_bound().is_none()
|
||||
})
|
||||
}
|
||||
|
@ -599,7 +599,8 @@ impl<'de, 'a> MapAccess<'de> for EnumMapVisitor<'a, 'de> {
|
||||
{
|
||||
match self.variant.take() {
|
||||
Some(Token::Str(variant)) => seed.deserialize(variant.into_deserializer()).map(Some),
|
||||
Some(Token::Bytes(variant)) => seed.deserialize(BytesDeserializer { value: variant })
|
||||
Some(Token::Bytes(variant)) => seed
|
||||
.deserialize(BytesDeserializer { value: variant })
|
||||
.map(Some),
|
||||
Some(Token::U32(variant)) => seed.deserialize(variant.into_deserializer()).map(Some),
|
||||
Some(other) => unexpected!(other),
|
||||
|
@ -2074,15 +2074,11 @@ fn test_flatten_untagged_enum() {
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||
#[serde(untagged)]
|
||||
enum Inner {
|
||||
Variant {
|
||||
a: i32,
|
||||
},
|
||||
Variant { a: i32 },
|
||||
}
|
||||
|
||||
let data = Outer {
|
||||
inner: Inner::Variant {
|
||||
a: 0,
|
||||
}
|
||||
inner: Inner::Variant { a: 0 },
|
||||
};
|
||||
|
||||
assert_tokens(
|
||||
@ -2118,12 +2114,8 @@ fn test_flatten_option() {
|
||||
|
||||
assert_tokens(
|
||||
&Outer {
|
||||
inner1: Some(Inner1 {
|
||||
inner1: 1,
|
||||
}),
|
||||
inner2: Some(Inner2 {
|
||||
inner2: 2,
|
||||
}),
|
||||
inner1: Some(Inner1 { inner1: 1 }),
|
||||
inner2: Some(Inner2 { inner2: 2 }),
|
||||
},
|
||||
&[
|
||||
Token::Map { len: None },
|
||||
@ -2137,9 +2129,7 @@ fn test_flatten_option() {
|
||||
|
||||
assert_tokens(
|
||||
&Outer {
|
||||
inner1: Some(Inner1 {
|
||||
inner1: 1,
|
||||
}),
|
||||
inner1: Some(Inner1 { inner1: 1 }),
|
||||
inner2: None,
|
||||
},
|
||||
&[
|
||||
@ -2153,9 +2143,7 @@ fn test_flatten_option() {
|
||||
assert_tokens(
|
||||
&Outer {
|
||||
inner1: None,
|
||||
inner2: Some(Inner2 {
|
||||
inner2: 2,
|
||||
}),
|
||||
inner2: Some(Inner2 { inner2: 2 }),
|
||||
},
|
||||
&[
|
||||
Token::Map { len: None },
|
||||
@ -2170,9 +2158,6 @@ fn test_flatten_option() {
|
||||
inner1: None,
|
||||
inner2: None,
|
||||
},
|
||||
&[
|
||||
Token::Map { len: None },
|
||||
Token::MapEnd,
|
||||
],
|
||||
&[Token::Map { len: None }, Token::MapEnd],
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user