From cbfdba382603f57b1bc839477bf7ea186c245599 Mon Sep 17 00:00:00 2001
From: David Tolnay <dtolnay@gmail.com>
Date: Tue, 14 Aug 2018 22:32:27 -0700
Subject: [PATCH] Use rustfmt to wrap and format comments

---
 serde/src/de/ignored_any.rs        | 10 ++++-
 serde/src/de/mod.rs                | 47 +++++++++++---------
 serde/src/private/de.rs            | 12 ++---
 serde/src/ser/mod.rs               | 71 +++++++++++++++++-------------
 serde_derive/src/bound.rs          |  3 +-
 serde_derive/src/de.rs             | 10 +++--
 serde_derive/src/internals/attr.rs |  6 +--
 serde_derive/src/internals/case.rs |  9 ++--
 serde_test/src/assert.rs           |  3 +-
 serde_test/src/configure.rs        |  9 +---
 serde_test/src/ser.rs              |  3 +-
 11 files changed, 102 insertions(+), 81 deletions(-)

diff --git a/serde/src/de/ignored_any.rs b/serde/src/de/ignored_any.rs
index 167ebe16..1e92146e 100644
--- a/serde/src/de/ignored_any.rs
+++ b/serde/src/de/ignored_any.rs
@@ -20,7 +20,9 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
 /// use std::fmt;
 /// use std::marker::PhantomData;
 ///
-/// use serde::de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess, IgnoredAny};
+/// use serde::de::{
+///     self, Deserialize, DeserializeSeed, Deserializer, IgnoredAny, SeqAccess, Visitor,
+/// };
 ///
 /// /// A seed that can be used to deserialize only the `n`th element of a sequence
 /// /// while efficiently discarding elements of any type before or after index `n`.
@@ -51,7 +53,11 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
 ///     type Value = T;
 ///
 ///     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
-///         write!(formatter, "a sequence in which we care about element {}", self.n)
+///         write!(
+///             formatter,
+///             "a sequence in which we care about element {}",
+///             self.n
+///         )
 ///     }
 ///
 ///     fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs
index 795f0cb6..e2db0218 100644
--- a/serde/src/de/mod.rs
+++ b/serde/src/de/mod.rs
@@ -659,7 +659,7 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
 /// use std::fmt;
 /// use std::marker::PhantomData;
 ///
-/// use serde::de::{Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess};
+/// use serde::de::{Deserialize, DeserializeSeed, Deserializer, SeqAccess, Visitor};
 ///
 /// // A DeserializeSeed implementation that uses stateful deserialization to
 /// // append array elements onto the end of an existing vector. The preexisting
@@ -806,16 +806,16 @@ where
 ///    - When serializing, all strings are handled equally. When deserializing,
 ///      there are three flavors of strings: transient, owned, and borrowed.
 ///  - **byte array** - \[u8\]
-///    - Similar to strings, during deserialization byte arrays can be transient,
-///      owned, or borrowed.
+///    - Similar to strings, during deserialization byte arrays can be
+///      transient, owned, or borrowed.
 ///  - **option**
 ///    - Either none or some value.
 ///  - **unit**
-///    - The type of `()` in Rust. It represents an anonymous value containing no
-///      data.
+///    - The type of `()` in Rust. It represents an anonymous value containing
+///      no data.
 ///  - **unit_struct**
-///    - For example `struct Unit` or `PhantomData<T>`. It represents a named value
-///      containing no data.
+///    - For example `struct Unit` or `PhantomData<T>`. It represents a named
+///      value containing no data.
 ///  - **unit_variant**
 ///    - For example the `E::A` and `E::B` in `enum E { A, B }`.
 ///  - **newtype_struct**
@@ -823,14 +823,15 @@ where
 ///  - **newtype_variant**
 ///    - For example the `E::N` in `enum E { N(u8) }`.
 ///  - **seq**
-///    - A variably sized heterogeneous sequence of values, for example `Vec<T>` or
-///      `HashSet<T>`. When serializing, the length may or may not be known before
-///      iterating through all the data. When deserializing, the length is determined
-///      by looking at the serialized data.
+///    - A variably sized heterogeneous sequence of values, for example `Vec<T>`
+///      or `HashSet<T>`. When serializing, the length may or may not be known
+///      before iterating through all the data. When deserializing, the length
+///      is determined by looking at the serialized data.
 ///  - **tuple**
-///    - A statically sized heterogeneous sequence of values for which the length
-///      will be known at deserialization time without looking at the serialized
-///      data, for example `(u8,)` or `(String, u64, Vec<T>)` or `[u64; 10]`.
+///    - A statically sized heterogeneous sequence of values for which the
+///      length will be known at deserialization time without looking at the
+///      serialized data, for example `(u8,)` or `(String, u64, Vec<T>)` or
+///      `[u64; 10]`.
 ///  - **tuple_struct**
 ///    - A named tuple, for example `struct Rgb(u8, u8, u8)`.
 ///  - **tuple_variant**
@@ -838,9 +839,9 @@ where
 ///  - **map**
 ///    - A heterogeneous key-value pairing, for example `BTreeMap<K, V>`.
 ///  - **struct**
-///    - A heterogeneous key-value pairing in which the keys are strings and will be
-///      known at deserialization time without looking at the serialized data, for
-///      example `struct S { r: u8, g: u8, b: u8 }`.
+///    - A heterogeneous key-value pairing in which the keys are strings and
+///      will be known at deserialization time without looking at the serialized
+///      data, for example `struct S { r: u8, g: u8, b: u8 }`.
 ///  - **struct_variant**
 ///    - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`.
 ///
@@ -855,7 +856,8 @@ where
 ///    type it sees in the input. JSON uses this approach when deserializing
 ///    `serde_json::Value` which is an enum that can represent any JSON
 ///    document. Without knowing what is in a JSON document, we can deserialize
-///    it to `serde_json::Value` by going through `Deserializer::deserialize_any`.
+///    it to `serde_json::Value` by going through
+///    `Deserializer::deserialize_any`.
 ///
 /// 2. The various `deserialize_*` methods. Non-self-describing formats like
 ///    Bincode need to be told what is in the input in order to deserialize it.
@@ -865,10 +867,11 @@ where
 ///    `Deserializer::deserialize_any`.
 ///
 /// When implementing `Deserialize`, you should avoid relying on
-/// `Deserializer::deserialize_any` unless you need to be told by the Deserializer
-/// what type is in the input. Know that relying on `Deserializer::deserialize_any`
-/// means your data type will be able to deserialize from self-describing
-/// formats only, ruling out Bincode and many others.
+/// `Deserializer::deserialize_any` unless you need to be told by the
+/// Deserializer what type is in the input. Know that relying on
+/// `Deserializer::deserialize_any` means your data type will be able to
+/// deserialize from self-describing formats only, ruling out Bincode and many
+/// others.
 ///
 /// [Serde data model]: https://serde.rs/data-model.html
 ///
diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs
index 8fdf6c36..8fb40ff1 100644
--- a/serde/src/private/de.rs
+++ b/serde/src/private/de.rs
@@ -832,8 +832,8 @@ mod content {
     }
 
     impl<'de, T> TaggedContentVisitor<'de, T> {
-        /// Visitor for the content of an internally tagged enum with the given tag
-        /// name.
+        /// Visitor for the content of an internally tagged enum with the given
+        /// tag name.
         pub fn new(name: &'static str) -> Self {
             TaggedContentVisitor {
                 tag_name: name,
@@ -1075,8 +1075,8 @@ mod content {
         Ok(value)
     }
 
-    /// Used when deserializing an internally tagged enum because the content will
-    /// be used exactly once.
+    /// Used when deserializing an internally tagged enum because the content
+    /// will be used exactly once.
     impl<'de, E> Deserializer<'de> for ContentDeserializer<'de, E>
     where
         E: de::Error,
@@ -1790,8 +1790,8 @@ mod content {
         Ok(value)
     }
 
-    /// Used when deserializing an untagged enum because the content may need to be
-    /// used more than once.
+    /// Used when deserializing an untagged enum because the content may need
+    /// to be used more than once.
     impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
     where
         E: de::Error,
diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs
index f37f8675..76d54485 100644
--- a/serde/src/ser/mod.rs
+++ b/serde/src/ser/mod.rs
@@ -219,7 +219,7 @@ pub trait Serialize {
     /// information about how to implement this method.
     ///
     /// ```rust
-    /// use serde::ser::{Serialize, Serializer, SerializeStruct};
+    /// use serde::ser::{Serialize, SerializeStruct, Serializer};
     ///
     /// struct Person {
     ///     name: String,
@@ -273,16 +273,16 @@ pub trait Serialize {
 ///    - When serializing, all strings are handled equally. When deserializing,
 ///      there are three flavors of strings: transient, owned, and borrowed.
 ///  - **byte array** - \[u8\]
-///    - Similar to strings, during deserialization byte arrays can be transient,
-///      owned, or borrowed.
+///    - Similar to strings, during deserialization byte arrays can be
+///      transient, owned, or borrowed.
 ///  - **option**
 ///    - Either none or some value.
 ///  - **unit**
-///    - The type of `()` in Rust. It represents an anonymous value containing no
-///      data.
+///    - The type of `()` in Rust. It represents an anonymous value containing
+///      no data.
 ///  - **unit_struct**
-///    - For example `struct Unit` or `PhantomData<T>`. It represents a named value
-///      containing no data.
+///    - For example `struct Unit` or `PhantomData<T>`. It represents a named
+///      value containing no data.
 ///  - **unit_variant**
 ///    - For example the `E::A` and `E::B` in `enum E { A, B }`.
 ///  - **newtype_struct**
@@ -290,14 +290,15 @@ pub trait Serialize {
 ///  - **newtype_variant**
 ///    - For example the `E::N` in `enum E { N(u8) }`.
 ///  - **seq**
-///    - A variably sized heterogeneous sequence of values, for example `Vec<T>` or
-///      `HashSet<T>`. When serializing, the length may or may not be known before
-///      iterating through all the data. When deserializing, the length is determined
-///      by looking at the serialized data.
+///    - A variably sized heterogeneous sequence of values, for example
+///      `Vec<T>` or `HashSet<T>`. When serializing, the length may or may not
+///      be known before iterating through all the data. When deserializing,
+///      the length is determined by looking at the serialized data.
 ///  - **tuple**
-///    - A statically sized heterogeneous sequence of values for which the length
-///      will be known at deserialization time without looking at the serialized
-///      data, for example `(u8,)` or `(String, u64, Vec<T>)` or `[u64; 10]`.
+///    - A statically sized heterogeneous sequence of values for which the
+///      length will be known at deserialization time without looking at the
+///      serialized data, for example `(u8,)` or `(String, u64, Vec<T>)` or
+///      `[u64; 10]`.
 ///  - **tuple_struct**
 ///    - A named tuple, for example `struct Rgb(u8, u8, u8)`.
 ///  - **tuple_variant**
@@ -305,9 +306,9 @@ pub trait Serialize {
 ///  - **map**
 ///    - A heterogeneous key-value pairing, for example `BTreeMap<K, V>`.
 ///  - **struct**
-///    - A heterogeneous key-value pairing in which the keys are strings and will be
-///      known at deserialization time without looking at the serialized data, for
-///      example `struct S { r: u8, g: u8, b: u8 }`.
+///    - A heterogeneous key-value pairing in which the keys are strings and
+///      will be known at deserialization time without looking at the
+///      serialized data, for example `struct S { r: u8, g: u8, b: u8 }`.
 ///  - **struct_variant**
 ///    - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`.
 ///
@@ -1110,7 +1111,7 @@ pub trait Serializer: Sized {
     /// ```
     ///
     /// ```rust
-    /// use serde::ser::{Serialize, Serializer, SerializeTuple};
+    /// use serde::ser::{Serialize, SerializeTuple, Serializer};
     ///
     /// const VRAM_SIZE: usize = 386;
     /// struct Vram([u16; VRAM_SIZE]);
@@ -1138,7 +1139,7 @@ pub trait Serializer: Sized {
     /// of data fields that will be serialized.
     ///
     /// ```rust
-    /// use serde::ser::{Serialize, Serializer, SerializeTupleStruct};
+    /// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
     ///
     /// struct Rgb(u8, u8, u8);
     ///
@@ -1170,7 +1171,7 @@ pub trait Serializer: Sized {
     /// and the `len` is the number of data fields that will be serialized.
     ///
     /// ```rust
-    /// use serde::ser::{Serialize, Serializer, SerializeTupleVariant};
+    /// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
     ///
     /// enum E {
     ///     T(u8, u8),
@@ -1264,7 +1265,7 @@ pub trait Serializer: Sized {
     /// data fields that will be serialized.
     ///
     /// ```rust
-    /// use serde::ser::{Serialize, Serializer, SerializeStruct};
+    /// use serde::ser::{Serialize, SerializeStruct, Serializer};
     ///
     /// struct Rgb {
     ///     r: u8,
@@ -1300,10 +1301,10 @@ pub trait Serializer: Sized {
     /// and the `len` is the number of data fields that will be serialized.
     ///
     /// ```rust
-    /// use serde::ser::{Serialize, Serializer, SerializeStructVariant};
+    /// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
     ///
     /// enum E {
-    ///     S { r: u8, g: u8, b: u8 }
+    ///     S { r: u8, g: u8, b: u8 },
     /// }
     ///
     /// impl Serialize for E {
@@ -1312,7 +1313,11 @@ pub trait Serializer: Sized {
     ///         S: Serializer,
     ///     {
     ///         match *self {
-    ///             E::S { ref r, ref g, ref b } => {
+    ///             E::S {
+    ///                 ref r,
+    ///                 ref g,
+    ///                 ref b,
+    ///             } => {
     ///                 let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
     ///                 sv.serialize_field("r", r)?;
     ///                 sv.serialize_field("g", g)?;
@@ -1375,8 +1380,8 @@ pub trait Serializer: Sized {
     /// method.
     ///
     /// ```rust
-    /// use std::collections::BTreeSet;
     /// use serde::{Serialize, Serializer};
+    /// use std::collections::BTreeSet;
     ///
     /// struct MapToUnit {
     ///     keys: BTreeSet<i32>,
@@ -1704,7 +1709,7 @@ pub trait SerializeTuple {
 /// # Example use
 ///
 /// ```rust
-/// use serde::ser::{Serialize, Serializer, SerializeTupleStruct};
+/// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
 ///
 /// struct Rgb(u8, u8, u8);
 ///
@@ -1749,7 +1754,7 @@ pub trait SerializeTupleStruct {
 /// # Example use
 ///
 /// ```rust
-/// use serde::ser::{Serialize, Serializer, SerializeTupleVariant};
+/// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
 ///
 /// enum E {
 ///     T(u8, u8),
@@ -1918,7 +1923,7 @@ pub trait SerializeMap {
 /// # Example use
 ///
 /// ```rust
-/// use serde::ser::{Serialize, Serializer, SerializeStruct};
+/// use serde::ser::{Serialize, SerializeStruct, Serializer};
 ///
 /// struct Rgb {
 ///     r: u8,
@@ -1978,10 +1983,10 @@ pub trait SerializeStruct {
 /// # Example use
 ///
 /// ```rust
-/// use serde::ser::{Serialize, Serializer, SerializeStructVariant};
+/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
 ///
 /// enum E {
-///     S { r: u8, g: u8, b: u8 }
+///     S { r: u8, g: u8, b: u8 },
 /// }
 ///
 /// impl Serialize for E {
@@ -1990,7 +1995,11 @@ pub trait SerializeStruct {
 ///         S: Serializer,
 ///     {
 ///         match *self {
-///             E::S { ref r, ref g, ref b } => {
+///             E::S {
+///                 ref r,
+///                 ref g,
+///                 ref b,
+///             } => {
 ///                 let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
 ///                 sv.serialize_field("r", r)?;
 ///                 sv.serialize_field("g", g)?;
diff --git a/serde_derive/src/bound.rs b/serde_derive/src/bound.rs
index 58e9ba02..a0aef3c9 100644
--- a/serde_derive/src/bound.rs
+++ b/serde_derive/src/bound.rs
@@ -90,7 +90,8 @@ pub fn with_where_predicates_from_variants(
 // Puts the given bound on any generic type parameters that are used in fields
 // for which filter returns true.
 //
-// For example, the following struct needs the bound `A: Serialize, B: Serialize`.
+// For example, the following struct needs the bound `A: Serialize, B:
+// Serialize`.
 //
 //     struct S<'b, A, B: 'b, C> {
 //         a: A,
diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs
index 20fa5a7f..e2ddfee1 100644
--- a/serde_derive/src/de.rs
+++ b/serde_derive/src/de.rs
@@ -837,7 +837,8 @@ fn deserialize_newtype_struct(
 
 #[cfg(feature = "deserialize_in_place")]
 fn deserialize_newtype_struct_in_place(params: &Parameters, field: &Field) -> TokenStream {
-    // We do not generate deserialize_in_place if every field has a deserialize_with.
+    // We do not generate deserialize_in_place if every field has a
+    // deserialize_with.
     assert!(field.attrs.deserialize_with().is_none());
 
     let delife = params.borrowed.de_lifetime();
@@ -941,8 +942,8 @@ fn deserialize_struct(
         quote!(mut __seq)
     };
 
-    // untagged struct variants do not get a visit_seq method.  The same applies to structs that
-    // only have a map representation.
+    // untagged struct variants do not get a visit_seq method. The same applies to
+    // structs that only have a map representation.
     let visit_seq = match *untagged {
         Untagged::No if !cattrs.has_flatten() => Some(quote! {
             #[inline]
@@ -2547,7 +2548,8 @@ fn deserialize_map_in_place(
         .map(|(i, field)| (field, field_i(i)))
         .collect();
 
-    // For deserialize_in_place, declare booleans for each field that will be deserialized.
+    // For deserialize_in_place, declare booleans for each field that will be
+    // deserialized.
     let let_flags = fields_names
         .iter()
         .filter(|&&(field, _)| !field.attrs.skip_deserializing())
diff --git a/serde_derive/src/internals/attr.rs b/serde_derive/src/internals/attr.rs
index 6779f4b1..31fbe080 100644
--- a/serde_derive/src/internals/attr.rs
+++ b/serde_derive/src/internals/attr.rs
@@ -989,9 +989,9 @@ impl Field {
             }
         }
 
-        // Is skip_deserializing, initialize the field to Default::default() unless a different
-        // default is specified by `#[serde(default = "...")]` on ourselves or our container (e.g.
-        // the struct we are in).
+        // Is skip_deserializing, initialize the field to Default::default() unless a
+        // different default is specified by `#[serde(default = "...")]` on
+        // ourselves or our container (e.g. the struct we are in).
         if let Default::None = *container_default {
             if skip_deserializing.0.value.is_some() {
                 default.set_if_none(Default::Default);
diff --git a/serde_derive/src/internals/case.rs b/serde_derive/src/internals/case.rs
index 577739b2..a84b7d0c 100644
--- a/serde_derive/src/internals/case.rs
+++ b/serde_derive/src/internals/case.rs
@@ -22,13 +22,16 @@ pub enum RenameRule {
     LowerCase,
     /// Rename direct children to "UPPERCASE" style.
     UPPERCASE,
-    /// Rename direct children to "PascalCase" style, as typically used for enum variants.
+    /// Rename direct children to "PascalCase" style, as typically used for
+    /// enum variants.
     PascalCase,
     /// Rename direct children to "camelCase" style.
     CamelCase,
-    /// Rename direct children to "snake_case" style, as commonly used for fields.
+    /// Rename direct children to "snake_case" style, as commonly used for
+    /// fields.
     SnakeCase,
-    /// Rename direct children to "SCREAMING_SNAKE_CASE" style, as commonly used for constants.
+    /// Rename direct children to "SCREAMING_SNAKE_CASE" style, as commonly
+    /// used for constants.
     ScreamingSnakeCase,
     /// Rename direct children to "kebab-case" style.
     KebabCase,
diff --git a/serde_test/src/assert.rs b/serde_test/src/assert.rs
index 82101409..fec6c9dc 100644
--- a/serde_test/src/assert.rs
+++ b/serde_test/src/assert.rs
@@ -95,7 +95,8 @@ where
     }
 }
 
-/// Asserts that `value` serializes to the given `tokens`, and then yields `error`.
+/// Asserts that `value` serializes to the given `tokens`, and then yields
+/// `error`.
 ///
 /// ```rust
 /// # #[macro_use]
diff --git a/serde_test/src/configure.rs b/serde_test/src/configure.rs
index 9fe73963..2f978f2a 100644
--- a/serde_test/src/configure.rs
+++ b/serde_test/src/configure.rs
@@ -19,7 +19,7 @@ pub struct Compact<T: ?Sized>(T);
 /// extern crate serde_test;
 ///
 /// use serde::{Deserialize, Deserializer, Serialize, Serializer};
-/// use serde_test::{Configure, Token, assert_tokens};
+/// use serde_test::{assert_tokens, Configure, Token};
 ///
 /// #[derive(Debug, PartialEq)]
 /// struct Example(u8, u8);
@@ -67,12 +67,7 @@ pub struct Compact<T: ?Sized>(T);
 ///             Token::TupleEnd,
 ///         ],
 ///     );
-///     assert_tokens(
-///         &Example(1, 0).readable(),
-///         &[
-///             Token::Str("1.0"),
-///         ],
-///     );
+///     assert_tokens(&Example(1, 0).readable(), &[Token::Str("1.0")]);
 /// }
 /// ```
 pub trait Configure {
diff --git a/serde_test/src/ser.rs b/serde_test/src/ser.rs
index e138712f..a0159c2c 100644
--- a/serde_test/src/ser.rs
+++ b/serde_test/src/ser.rs
@@ -11,7 +11,8 @@ use serde::{ser, Serialize};
 use error::Error;
 use token::Token;
 
-/// A `Serializer` that ensures that a value serializes to a given list of tokens.
+/// A `Serializer` that ensures that a value serializes to a given list of
+/// tokens.
 #[derive(Debug)]
 pub struct Serializer<'a> {
     tokens: &'a [Token],