Skip to content

Commit

Permalink
Format with rustfmt-nightly 0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 24, 2017
1 parent c2b390f commit ee75e6c
Show file tree
Hide file tree
Showing 32 changed files with 2,035 additions and 1,894 deletions.
2 changes: 1 addition & 1 deletion serde/src/de/ignored_any.rs
Expand Up @@ -8,7 +8,7 @@

use lib::*;

use de::{Deserialize, Deserializer, Visitor, SeqAccess, MapAccess, Error};
use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};

/// An efficient way of discarding data from a deserializer.
///
Expand Down
90 changes: 60 additions & 30 deletions serde/src/de/impls.rs
Expand Up @@ -52,7 +52,6 @@ impl<'de> Deserialize<'de> for () {

struct BoolVisitor;


impl<'de> Visitor<'de> for BoolVisitor {
type Value = bool;

Expand Down Expand Up @@ -253,7 +252,10 @@ impl<'de> Visitor<'de> for StringVisitor {
{
match String::from_utf8(v) {
Ok(s) => Ok(s),
Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self),),
Err(e) => Err(Error::invalid_value(
Unexpected::Bytes(&e.into_bytes()),
&self,
)),
}
}
}
Expand Down Expand Up @@ -306,7 +308,10 @@ impl<'a, 'de> Visitor<'de> for StringInPlaceVisitor<'a> {
*self.0 = s;
Ok(())
}
Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self),),
Err(e) => Err(Error::invalid_value(
Unexpected::Bytes(&e.into_bytes()),
&self,
)),
}
}
}
Expand Down Expand Up @@ -529,7 +534,9 @@ where
where
D: Deserializer<'de>,
{
deserializer.deserialize_option(OptionVisitor { marker: PhantomData })
deserializer.deserialize_option(OptionVisitor {
marker: PhantomData,
})
}

// The Some variant's repr is opaque, so we can't play cute tricks with its
Expand Down Expand Up @@ -566,7 +573,9 @@ impl<'de, T> Deserialize<'de> for PhantomData<T> {
where
D: Deserializer<'de>,
{
let visitor = PhantomDataVisitor { marker: PhantomData };
let visitor = PhantomDataVisitor {
marker: PhantomData,
};
deserializer.deserialize_unit_struct("PhantomData", visitor)
}
}
Expand Down Expand Up @@ -699,7 +708,8 @@ seq_impl!(
LinkedList::clear,
LinkedList::new(),
nop_reserve,
LinkedList::push_back);
LinkedList::push_back
);

#[cfg(feature = "std")]
seq_impl!(
Expand All @@ -719,7 +729,8 @@ seq_impl!(
Vec::clear,
Vec::with_capacity(size_hint::cautious(seq.size_hint())),
Vec::reserve,
Vec::push);
Vec::push
);

#[cfg(any(feature = "std", feature = "alloc"))]
seq_impl!(
Expand All @@ -729,7 +740,8 @@ seq_impl!(
VecDeque::clear,
VecDeque::with_capacity(size_hint::cautious(seq.size_hint())),
VecDeque::reserve,
VecDeque::push_back);
VecDeque::push_back
);

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -740,7 +752,9 @@ struct ArrayInPlaceVisitor<'a, A: 'a>(&'a mut A);

impl<A> ArrayVisitor<A> {
fn new() -> Self {
ArrayVisitor { marker: PhantomData }
ArrayVisitor {
marker: PhantomData,
}
}
}

Expand Down Expand Up @@ -1257,7 +1271,12 @@ impl<'de> Deserialize<'de> for net::SocketAddr {
parse_socket_impl!(net::SocketAddrV4, net::SocketAddrV4::new);

#[cfg(feature = "std")]
parse_socket_impl!(net::SocketAddrV6, |ip, port| net::SocketAddrV6::new(ip, port, 0, 0));
parse_socket_impl!(net::SocketAddrV6, |ip, port| net::SocketAddrV6::new(
ip,
port,
0,
0
));

////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -1368,7 +1387,9 @@ impl<'de> Visitor<'de> for OsStringVisitor {

match try!(data.variant()) {
(OsStringKind::Unix, v) => v.newtype_variant().map(OsString::from_vec),
(OsStringKind::Windows, _) => Err(Error::custom("cannot deserialize Windows OS string on Unix",),),
(OsStringKind::Windows, _) => Err(Error::custom(
"cannot deserialize Windows OS string on Unix",
)),
}
}

Expand All @@ -1380,11 +1401,11 @@ impl<'de> Visitor<'de> for OsStringVisitor {
use std::os::windows::ffi::OsStringExt;

match try!(data.variant()) {
(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",),),
(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",
)),
}
}
}
Expand Down Expand Up @@ -1710,13 +1731,17 @@ impl<'de> Deserialize<'de> for SystemTime {
match key {
Field::Secs => {
if secs.is_some() {
return Err(<A::Error as Error>::duplicate_field("secs_since_epoch"));
return Err(<A::Error as Error>::duplicate_field(
"secs_since_epoch",
));
}
secs = Some(try!(map.next_value()));
}
Field::Nanos => {
if nanos.is_some() {
return Err(<A::Error as Error>::duplicate_field("nanos_since_epoch"));
return Err(<A::Error as Error>::duplicate_field(
"nanos_since_epoch",
));
}
nanos = Some(try!(map.next_value()));
}
Expand Down Expand Up @@ -1880,7 +1905,13 @@ where
}

const FIELDS: &'static [&'static str] = &["start", "end"];
deserializer.deserialize_struct("Range", FIELDS, RangeVisitor { phantom: PhantomData })
deserializer.deserialize_struct(
"Range",
FIELDS,
RangeVisitor {
phantom: PhantomData,
},
)
}
}

Expand Down Expand Up @@ -1945,9 +1976,10 @@ where
match value {
0 => Ok(Field::Ok),
1 => Ok(Field::Err),
_ => {
Err(Error::invalid_value(Unexpected::Unsigned(value as u64), &self),)
}
_ => Err(Error::invalid_value(
Unexpected::Unsigned(value as u64),
&self,
)),
}
}

Expand All @@ -1969,14 +2001,12 @@ where
match value {
b"Ok" => Ok(Field::Ok),
b"Err" => Ok(Field::Err),
_ => {
match str::from_utf8(value) {
Ok(value) => Err(Error::unknown_variant(value, VARIANTS)),
Err(_) => {
Err(Error::invalid_value(Unexpected::Bytes(value), &self))
}
_ => match str::from_utf8(value) {
Ok(value) => Err(Error::unknown_variant(value, VARIANTS)),
Err(_) => {
Err(Error::invalid_value(Unexpected::Bytes(value), &self))
}
}
},
}
}
}
Expand Down Expand Up @@ -2020,7 +2050,7 @@ where
#[cfg(feature = "std")]
impl<'de, T> Deserialize<'de> for Wrapping<T>
where
T: Deserialize<'de>
T: Deserialize<'de>,
{
fn deserialize<D>(deserializer: D) -> Result<Wrapping<T>, D::Error>
where
Expand Down
7 changes: 5 additions & 2 deletions serde/src/de/mod.rs
Expand Up @@ -526,7 +526,8 @@ pub trait Deserialize<'de>: Sized {
/// than it deserves.
#[doc(hidden)]
fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>
where D: Deserializer<'de>
where
D: Deserializer<'de>,
{
// Default implementation just delegates to `deserialize` impl.
*place = Deserialize::deserialize(deserializer)?;
Expand Down Expand Up @@ -1106,7 +1107,9 @@ pub trait Deserializer<'de>: Sized {
/// change, as a value serialized in human-readable mode is not required to
/// deserialize from the same data in compact mode.
#[inline]
fn is_human_readable(&self) -> bool { true }
fn is_human_readable(&self) -> bool {
true
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
48 changes: 34 additions & 14 deletions serde/src/de/value.rs
Expand Up @@ -37,7 +37,7 @@

use lib::*;

use de::{self, IntoDeserializer, Expected, SeqAccess};
use de::{self, Expected, IntoDeserializer, SeqAccess};
use private::de::size_hint;
use ser;
use self::private::{First, Second};
Expand All @@ -62,7 +62,9 @@ impl de::Error for Error {
where
T: Display,
{
Error { err: msg.to_string().into_boxed_str() }
Error {
err: msg.to_string().into_boxed_str(),
}
}

#[cfg(not(any(feature = "std", feature = "alloc")))]
Expand Down Expand Up @@ -112,7 +114,9 @@ where
type Deserializer = UnitDeserializer<E>;

fn into_deserializer(self) -> UnitDeserializer<E> {
UnitDeserializer { marker: PhantomData }
UnitDeserializer {
marker: PhantomData,
}
}
}

Expand Down Expand Up @@ -658,7 +662,10 @@ where
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(self.count + remaining, &ExpectedInSeq(self.count)),)
Err(de::Error::invalid_length(
self.count + remaining,
&ExpectedInSeq(self.count),
))
}
}
}
Expand Down Expand Up @@ -852,7 +859,10 @@ where
} else {
// First argument is the number of elements in the data, second
// argument is the number of elements expected by the Deserialize.
Err(de::Error::invalid_length(self.count + remaining, &ExpectedInMap(self.count)),)
Err(de::Error::invalid_length(
self.count + remaining,
&ExpectedInMap(self.count),
))
}
}
}
Expand Down Expand Up @@ -901,11 +911,7 @@ where
Ok(value)
}

fn deserialize_tuple<V>(
self,
len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>
fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
Expand Down Expand Up @@ -1223,7 +1229,12 @@ mod private {
}

pub fn unit_only<T, E>(t: T) -> (T, UnitOnly<E>) {
(t, UnitOnly { marker: PhantomData })
(
t,
UnitOnly {
marker: PhantomData,
},
)
}

impl<'de, E> de::VariantAccess<'de> for UnitOnly<E>
Expand All @@ -1240,14 +1251,20 @@ mod private {
where
T: de::DeserializeSeed<'de>,
{
Err(de::Error::invalid_type(Unexpected::UnitVariant, &"newtype variant"),)
Err(de::Error::invalid_type(
Unexpected::UnitVariant,
&"newtype variant",
))
}

fn tuple_variant<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
where
V: de::Visitor<'de>,
{
Err(de::Error::invalid_type(Unexpected::UnitVariant, &"tuple variant"),)
Err(de::Error::invalid_type(
Unexpected::UnitVariant,
&"tuple variant",
))
}

fn struct_variant<V>(
Expand All @@ -1258,7 +1275,10 @@ mod private {
where
V: de::Visitor<'de>,
{
Err(de::Error::invalid_type(Unexpected::UnitVariant, &"struct variant"),)
Err(de::Error::invalid_type(
Unexpected::UnitVariant,
&"struct variant",
))
}
}

Expand Down
2 changes: 1 addition & 1 deletion serde/src/export.rs
Expand Up @@ -12,7 +12,7 @@ pub use lib::default::Default;
pub use lib::fmt::{self, Formatter};
pub use lib::marker::PhantomData;
pub use lib::option::Option::{self, None, Some};
pub use lib::result::Result::{self, Ok, Err};
pub use lib::result::Result::{self, Err, Ok};

pub use self::string::from_utf8_lossy;

Expand Down

0 comments on commit ee75e6c

Please sign in to comment.