Format where-clauses in serde docs like rustfmt

This commit is contained in:
David Tolnay 2018-05-05 18:33:29 -07:00
parent f263e3fcec
commit d1297deb36
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
4 changed files with 183 additions and 95 deletions

View File

@ -45,7 +45,8 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
/// }
///
/// impl<'de, T> Visitor<'de> for NthElement<T>
/// where T: Deserialize<'de>
/// where
/// T: Deserialize<'de>,
/// {
/// type Value = T;
///
@ -54,7 +55,8 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
/// }
///
/// fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
/// where A: SeqAccess<'de>
/// where
/// A: SeqAccess<'de>,
/// {
/// // Skip over the first `n` elements.
/// for i in 0..self.n {
@ -82,19 +84,22 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
/// }
///
/// impl<'de, T> DeserializeSeed<'de> for NthElement<T>
/// where T: Deserialize<'de>
/// where
/// T: Deserialize<'de>,
/// {
/// type Value = T;
///
/// fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
/// where D: Deserializer<'de>
/// where
/// D: Deserializer<'de>,
/// {
/// deserializer.deserialize_seq(self)
/// }
/// }
///
/// # fn example<'de, D>(deserializer: D) -> Result<(), D::Error>
/// # where D: Deserializer<'de>
/// # where
/// # D: Deserializer<'de>,
/// # {
/// // Deserialize only the sequence element at index 3 from this deserializer.
/// // The element at index 3 is required to be a string. Elements before and

View File

@ -172,7 +172,8 @@ macro_rules! declare_error_trait {
///
/// impl<'de> Deserialize<'de> for IpAddr {
/// fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
/// where D: Deserializer<'de>
/// where
/// D: Deserializer<'de>,
/// {
/// let s = try!(String::deserialize(deserializer));
/// s.parse().map_err(de::Error::custom)
@ -306,7 +307,8 @@ declare_error_trait!(Error: Sized + Debug + Display);
/// # }
/// #
/// fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
/// where E: de::Error
/// where
/// E: de::Error,
/// {
/// Err(de::Error::invalid_type(Unexpected::Bool(v), &self))
/// }
@ -430,7 +432,8 @@ impl<'a> fmt::Display for Unexpected<'a> {
/// # }
/// #
/// fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
/// where E: de::Error
/// where
/// E: de::Error,
/// {
/// Err(de::Error::invalid_type(Unexpected::Bool(v), &self))
/// }
@ -443,7 +446,8 @@ impl<'a> fmt::Display for Unexpected<'a> {
/// # use serde::de::{self, Unexpected};
/// #
/// # fn example<E>() -> Result<(), E>
/// # where E: de::Error
/// # where
/// # E: de::Error,
/// # {
/// # let v = true;
/// return Err(de::Error::invalid_type(Unexpected::Bool(v), &"a negative integer"));
@ -557,11 +561,13 @@ pub trait Deserialize<'de>: Sized {
/// #
/// # trait Ignore {
/// fn from_str<'a, T>(s: &'a str) -> Result<T>
/// where T: Deserialize<'a>;
/// where
/// T: Deserialize<'a>;
///
/// fn from_reader<R, T>(rdr: R) -> Result<T>
/// where R: Read,
/// T: DeserializeOwned;
/// where
/// R: Read,
/// T: DeserializeOwned;
/// # }
/// ```
pub trait DeserializeOwned: for<'de> Deserialize<'de> {}
@ -637,7 +643,8 @@ where
/// struct ExtendVec<'a, T: 'a>(&'a mut Vec<T>);
///
/// impl<'de, 'a, T> DeserializeSeed<'de> for ExtendVec<'a, T>
/// where T: Deserialize<'de>
/// where
/// T: Deserialize<'de>,
/// {
/// // The return type of the `deserialize` method. This implementation
/// // appends onto an existing vector but does not create any new data
@ -645,14 +652,16 @@ where
/// type Value = ();
///
/// fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
/// where D: Deserializer<'de>
/// where
/// D: Deserializer<'de>,
/// {
/// // Visitor implementation that will walk an inner array of the JSON
/// // input.
/// struct ExtendVecVisitor<'a, T: 'a>(&'a mut Vec<T>);
///
/// impl<'de, 'a, T> Visitor<'de> for ExtendVecVisitor<'a, T>
/// where T: Deserialize<'de>
/// where
/// T: Deserialize<'de>,
/// {
/// type Value = ();
///
@ -661,7 +670,8 @@ where
/// }
///
/// fn visit_seq<A>(self, mut seq: A) -> Result<(), A::Error>
/// where A: SeqAccess<'de>
/// where
/// A: SeqAccess<'de>,
/// {
/// // Visit each element in the inner array and push it onto
/// // the existing vector.
@ -680,7 +690,8 @@ where
/// struct FlattenedVecVisitor<T>(PhantomData<T>);
///
/// impl<'de, T> Visitor<'de> for FlattenedVecVisitor<T>
/// where T: Deserialize<'de>
/// where
/// T: Deserialize<'de>,
/// {
/// // This Visitor constructs a single Vec<T> to hold the flattened
/// // contents of the inner arrays.
@ -691,7 +702,8 @@ where
/// }
///
/// fn visit_seq<A>(self, mut seq: A) -> Result<Vec<T>, A::Error>
/// where A: SeqAccess<'de>
/// where
/// A: SeqAccess<'de>,
/// {
/// // Create a single Vec to hold the flattened contents.
/// let mut vec = Vec::new();
@ -707,7 +719,8 @@ where
/// }
///
/// # fn example<'de, D>(deserializer: D) -> Result<(), D::Error>
/// # where D: Deserializer<'de>
/// # where
/// # D: Deserializer<'de>,
/// # {
/// let visitor = FlattenedVecVisitor(PhantomData);
/// let flattened: Vec<u64> = deserializer.deserialize_seq(visitor)?;
@ -1092,7 +1105,8 @@ pub trait Deserializer<'de>: Sized {
///
/// impl<'de> Deserialize<'de> for Timestamp {
/// fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
/// where D: Deserializer<'de>
/// where
/// D: Deserializer<'de>,
/// {
/// if deserializer.is_human_readable() {
/// // Deserialize from a human-readable string like "2015-05-15T17:01:00Z".
@ -1143,7 +1157,8 @@ pub trait Deserializer<'de>: Sized {
/// }
///
/// fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
/// where E: de::Error
/// where
/// E: de::Error,
/// {
/// if s.len() >= self.min {
/// Ok(s.to_owned())
@ -1823,15 +1838,18 @@ pub trait VariantAccess<'de>: Sized {
/// }
/// #
/// # fn newtype_variant_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
/// # where T: DeserializeSeed<'de>
/// # where
/// # T: DeserializeSeed<'de>,
/// # { unimplemented!() }
/// #
/// # fn tuple_variant<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
/// # where V: Visitor<'de>
/// # where
/// # V: Visitor<'de>,
/// # { unimplemented!() }
/// #
/// # fn struct_variant<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
/// # where V: Visitor<'de>
/// # where
/// # V: Visitor<'de>,
/// # { unimplemented!() }
/// # }
/// ```
@ -1858,7 +1876,8 @@ pub trait VariantAccess<'de>: Sized {
/// # }
/// #
/// fn newtype_variant_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
/// where T: DeserializeSeed<'de>
/// where
/// T: DeserializeSeed<'de>,
/// {
/// // What the data actually contained; suppose it is a unit variant.
/// let unexp = Unexpected::UnitVariant;
@ -1866,11 +1885,13 @@ pub trait VariantAccess<'de>: Sized {
/// }
/// #
/// # fn tuple_variant<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
/// # where V: Visitor<'de>
/// # where
/// # V: Visitor<'de>,
/// # { unimplemented!() }
/// #
/// # fn struct_variant<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
/// # where V: Visitor<'de>
/// # where
/// # V: Visitor<'de>,
/// # { unimplemented!() }
/// # }
/// ```
@ -1911,13 +1932,15 @@ pub trait VariantAccess<'de>: Sized {
/// # }
/// #
/// # fn newtype_variant_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
/// # where T: DeserializeSeed<'de>
/// # where
/// # T: DeserializeSeed<'de>,
/// # { unimplemented!() }
/// #
/// fn tuple_variant<V>(self,
/// _len: usize,
/// _visitor: V) -> Result<V::Value, Self::Error>
/// where V: Visitor<'de>
/// where
/// V: Visitor<'de>,
/// {
/// // What the data actually contained; suppose it is a unit variant.
/// let unexp = Unexpected::UnitVariant;
@ -1925,7 +1948,8 @@ pub trait VariantAccess<'de>: Sized {
/// }
/// #
/// # fn struct_variant<V>(self, _: &[&str], _: V) -> Result<V::Value, Self::Error>
/// # where V: Visitor<'de>
/// # where
/// # V: Visitor<'de>,
/// # { unimplemented!() }
/// # }
/// ```
@ -1953,17 +1977,20 @@ pub trait VariantAccess<'de>: Sized {
/// # }
/// #
/// # fn newtype_variant_seed<T>(self, _: T) -> Result<T::Value, Self::Error>
/// # where T: DeserializeSeed<'de>
/// # where
/// # T: DeserializeSeed<'de>,
/// # { unimplemented!() }
/// #
/// # fn tuple_variant<V>(self, _: usize, _: V) -> Result<V::Value, Self::Error>
/// # where V: Visitor<'de>
/// # where
/// # V: Visitor<'de>,
/// # { unimplemented!() }
/// #
/// fn struct_variant<V>(self,
/// _fields: &'static [&'static str],
/// _visitor: V) -> Result<V::Value, Self::Error>
/// where V: Visitor<'de>
/// where
/// V: Visitor<'de>,
/// {
/// // What the data actually contained; suppose it is a unit variant.
/// let unexp = Unexpected::UnitVariant;

View File

@ -31,14 +31,16 @@
/// # type Error = value::Error;
/// #
/// # fn deserialize_any<V>(self, _: V) -> Result<V::Value, Self::Error>
/// # where V: Visitor<'de>
/// # where
/// # V: Visitor<'de>,
/// # {
/// # unimplemented!()
/// # }
/// #
/// #[inline]
/// fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
/// where V: Visitor<'de>
/// where
/// V: Visitor<'de>,
/// {
/// self.deserialize_any(visitor)
/// }
@ -69,7 +71,8 @@
/// # type Error = value::Error;
/// #
/// fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
/// where V: Visitor<'de>
/// where
/// V: Visitor<'de>,
/// {
/// /* ... */
/// # let _ = visitor;
@ -105,7 +108,8 @@
/// # type Error = value::Error;
/// #
/// # fn deserialize_any<W>(self, visitor: W) -> Result<W::Value, Self::Error>
/// # where W: Visitor<'q>
/// # where
/// # W: Visitor<'q>,
/// # {
/// # unimplemented!()
/// # }

View File

@ -152,7 +152,8 @@ macro_rules! declare_error_trait {
///
/// impl Serialize for Path {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match self.to_str() {
/// Some(s) => serializer.serialize_str(s),
@ -223,7 +224,8 @@ pub trait Serialize {
/// // This is what #[derive(Serialize)] would generate.
/// impl Serialize for Person {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut s = serializer.serialize_struct("Person", 3)?;
/// s.serialize_field("name", &self.name)?;
@ -377,7 +379,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for bool {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_bool(*self)
/// }
@ -403,7 +406,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for i8 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_i8(*self)
/// }
@ -429,7 +433,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for i16 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_i16(*self)
/// }
@ -455,7 +460,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for i32 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_i32(*self)
/// }
@ -477,7 +483,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for i64 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_i64(*self)
/// }
@ -503,7 +510,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for u8 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_u8(*self)
/// }
@ -529,7 +537,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for u16 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_u16(*self)
/// }
@ -555,7 +564,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for u32 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_u32(*self)
/// }
@ -577,7 +587,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for u64 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_u64(*self)
/// }
@ -603,7 +614,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for f32 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_f32(*self)
/// }
@ -625,7 +637,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for f64 {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_f64(*self)
/// }
@ -650,7 +663,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for char {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_char(*self)
/// }
@ -672,7 +686,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for str {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_str(self)
/// }
@ -737,10 +752,12 @@ pub trait Serializer: Sized {
/// # use Option::{Some, None};
/// #
/// impl<T> Serialize for Option<T>
/// where T: Serialize
/// where
/// T: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// Some(ref value) => serializer.serialize_some(value),
@ -770,10 +787,12 @@ pub trait Serializer: Sized {
/// # use Option::{Some, None};
/// #
/// impl<T> Serialize for Option<T>
/// where T: Serialize
/// where
/// T: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// Some(ref value) => serializer.serialize_some(value),
@ -802,7 +821,8 @@ pub trait Serializer: Sized {
/// #
/// impl Serialize for () {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_unit()
/// }
@ -823,7 +843,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for Nothing {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_unit_struct("Nothing")
/// }
@ -847,7 +868,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for E {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// E::A => serializer.serialize_unit_variant("E", 0, "A"),
@ -876,7 +898,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for Millimeters {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.serialize_newtype_struct("Millimeters", &self.0)
/// }
@ -906,7 +929,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for E {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// E::M(ref s) => serializer.serialize_newtype_variant("E", 0, "M", s),
@ -956,10 +980,12 @@ pub trait Serializer: Sized {
/// use serde::ser::{Serialize, Serializer, SerializeSeq};
///
/// impl<T> Serialize for Vec<T>
/// where T: Serialize
/// where
/// T: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut seq = serializer.serialize_seq(Some(self.len()))?;
/// for element in self {
@ -988,12 +1014,14 @@ pub trait Serializer: Sized {
/// # struct Tuple3<A, B, C>(A, B, C);
/// #
/// # impl<A, B, C> Serialize for Tuple3<A, B, C>
/// where A: Serialize,
/// B: Serialize,
/// C: Serialize
/// where
/// A: Serialize,
/// B: Serialize,
/// C: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut tup = serializer.serialize_tuple(3)?;
/// tup.serialize_element(&self.0)?;
@ -1012,7 +1040,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for Vram {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut seq = serializer.serialize_tuple(VRAM_SIZE)?;
/// for element in &self.0[..] {
@ -1038,7 +1067,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for Rgb {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?;
/// ts.serialize_field(&self.0)?;
@ -1072,7 +1102,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for E {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// E::T(ref a, ref b) => {
@ -1130,11 +1161,13 @@ pub trait Serializer: Sized {
/// use serde::ser::{Serialize, Serializer, SerializeMap};
///
/// impl<K, V> Serialize for HashMap<K, V>
/// where K: Serialize,
/// V: Serialize
/// where
/// K: Serialize,
/// V: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut map = serializer.serialize_map(Some(self.len()))?;
/// for (k, v) in self {
@ -1164,7 +1197,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for Rgb {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut rgb = serializer.serialize_struct("Rgb", 3)?;
/// rgb.serialize_field("r", &self.r)?;
@ -1197,7 +1231,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for E {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// E::S { ref r, ref g, ref b } => {
@ -1234,7 +1269,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for SecretlyOneHigher {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.collect_seq(self.data.iter().map(|x| x + 1))
/// }
@ -1272,7 +1308,8 @@ pub trait Serializer: Sized {
/// // Serializes as a map in which the values are all unit.
/// impl Serialize for MapToUnit {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.collect_map(self.keys.iter().map(|k| (k, ())))
/// }
@ -1312,7 +1349,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for DateTime {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.collect_str(&format_args!("{:?}{:?}",
/// self.naive_local(),
@ -1352,7 +1390,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for DateTime {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// serializer.collect_str(&format_args!("{:?}{:?}",
/// self.naive_local(),
@ -1393,7 +1432,8 @@ pub trait Serializer: Sized {
///
/// impl Serialize for Timestamp {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// if serializer.is_human_readable() {
/// // Serialize to a human-readable string "2015-05-15T17:01:00Z".
@ -1442,10 +1482,12 @@ pub trait Serializer: Sized {
/// use serde::ser::{Serialize, Serializer, SerializeSeq};
///
/// impl<T> Serialize for Vec<T>
/// where T: Serialize
/// where
/// T: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut seq = serializer.serialize_seq(Some(self.len()))?;
/// for element in self {
@ -1485,12 +1527,14 @@ pub trait SerializeSeq {
/// # struct Tuple3<A, B, C>(A, B, C);
/// #
/// # impl<A, B, C> Serialize for Tuple3<A, B, C>
/// where A: Serialize,
/// B: Serialize,
/// C: Serialize
/// where
/// A: Serialize,
/// B: Serialize,
/// C: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut tup = serializer.serialize_tuple(3)?;
/// tup.serialize_element(&self.0)?;
@ -1529,10 +1573,12 @@ pub trait SerializeSeq {
/// # }
/// #
/// # impl<T> Serialize for Array<T>
/// where T: Serialize
/// where
/// T: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut seq = serializer.serialize_tuple(16)?;
/// for element in self {
@ -1567,7 +1613,8 @@ pub trait SerializeTuple {
///
/// impl Serialize for Rgb {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?;
/// ts.serialize_field(&self.0)?;
@ -1605,7 +1652,8 @@ pub trait SerializeTupleStruct {
///
/// impl Serialize for E {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// E::T(ref a, ref b) => {
@ -1666,11 +1714,13 @@ pub trait SerializeTupleVariant {
/// use serde::ser::{Serialize, Serializer, SerializeMap};
///
/// impl<K, V> Serialize for HashMap<K, V>
/// where K: Serialize,
/// V: Serialize
/// where
/// K: Serialize,
/// V: Serialize,
/// {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut map = serializer.serialize_map(Some(self.len()))?;
/// for (k, v) in self {
@ -1754,7 +1804,8 @@ pub trait SerializeMap {
///
/// impl Serialize for Rgb {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// let mut rgb = serializer.serialize_struct("Rgb", 3)?;
/// rgb.serialize_field("r", &self.r)?;
@ -1802,7 +1853,8 @@ pub trait SerializeStruct {
///
/// impl Serialize for E {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// where S: Serializer
/// where
/// S: Serializer,
/// {
/// match *self {
/// E::S { ref r, ref g, ref b } => {