formatting fixup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-07-30 15:20:55 +02:00
parent d5ee03da9f
commit 2a4af329a7
2 changed files with 47 additions and 31 deletions

View File

@ -673,11 +673,15 @@ fn wrap_serialize_with(
with: &syn::Path,
) -> (TokenStream, Ident) {
let helper_name = Ident::new(
&format!("SerializeWith{}", crate::util::to_camel_case(&name.to_string())),
&format!(
"SerializeWith{}",
crate::util::to_camel_case(&name.to_string())
),
name.span(),
);
(quote_spanned! { span =>
(
quote_spanned! { span =>
struct #helper_name<'a>(&'a #ty);
impl<'a> ::serde::ser::Serialize for #helper_name<'a> {
@ -688,7 +692,9 @@ fn wrap_serialize_with(
#with(self.0, serializer)
}
}
}, helper_name)
},
helper_name,
)
}
fn named_struct_derive_serialize(
@ -749,11 +755,15 @@ fn wrap_deserialize_with(
with: &syn::Path,
) -> (TokenStream, Ident) {
let helper_name = Ident::new(
&format!("DeserializeWith{}", crate::util::to_camel_case(&name.to_string())),
&format!(
"DeserializeWith{}",
crate::util::to_camel_case(&name.to_string())
),
name.span(),
);
(quote_spanned! { span =>
(
quote_spanned! { span =>
struct #helper_name<'de> {
value: #ty,
_lifetime: ::std::marker::PhantomData<&'de ()>,
@ -770,7 +780,9 @@ fn wrap_deserialize_with(
})
}
}
}, helper_name)
},
helper_name,
)
}
fn named_struct_derive_deserialize(

View File

@ -95,11 +95,15 @@ impl<T: AsRef<str>> TestMinMaxLen<mark::Default> for T {
impl<T: AsRef<str>> TestMinMaxLen<mark::Special> for Option<T> {
#[inline]
fn test_minimum_length(&self, minimum: usize) -> bool {
self.as_ref().map(|x| x.as_ref().len() >= minimum).unwrap_or(true)
self.as_ref()
.map(|x| x.as_ref().len() >= minimum)
.unwrap_or(true)
}
#[inline]
fn test_maximum_length(&self, maximum: usize) -> bool {
self.as_ref().map(|x| x.as_ref().len() <= maximum).unwrap_or(true)
self.as_ref()
.map(|x| x.as_ref().len() <= maximum)
.unwrap_or(true)
}
}