Use rustfmt to wrap and format comments

This commit is contained in:
David Tolnay 2018-08-14 22:32:27 -07:00
parent 5985b7edaf
commit cbfdba3826
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
11 changed files with 102 additions and 81 deletions

View File

@ -20,7 +20,9 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
/// use std::fmt; /// use std::fmt;
/// use std::marker::PhantomData; /// 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 /// /// 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`. /// /// 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; /// type Value = T;
/// ///
/// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { /// 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> /// fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>

View File

@ -659,7 +659,7 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
/// use std::fmt; /// use std::fmt;
/// use std::marker::PhantomData; /// 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 /// // A DeserializeSeed implementation that uses stateful deserialization to
/// // append array elements onto the end of an existing vector. The preexisting /// // 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, /// - When serializing, all strings are handled equally. When deserializing,
/// there are three flavors of strings: transient, owned, and borrowed. /// there are three flavors of strings: transient, owned, and borrowed.
/// - **byte array** - \[u8\] /// - **byte array** - \[u8\]
/// - Similar to strings, during deserialization byte arrays can be transient, /// - Similar to strings, during deserialization byte arrays can be
/// owned, or borrowed. /// transient, owned, or borrowed.
/// - **option** /// - **option**
/// - Either none or some value. /// - Either none or some value.
/// - **unit** /// - **unit**
/// - The type of `()` in Rust. It represents an anonymous value containing no /// - The type of `()` in Rust. It represents an anonymous value containing
/// data. /// no data.
/// - **unit_struct** /// - **unit_struct**
/// - For example `struct Unit` or `PhantomData<T>`. It represents a named value /// - For example `struct Unit` or `PhantomData<T>`. It represents a named
/// containing no data. /// value containing no data.
/// - **unit_variant** /// - **unit_variant**
/// - For example the `E::A` and `E::B` in `enum E { A, B }`. /// - For example the `E::A` and `E::B` in `enum E { A, B }`.
/// - **newtype_struct** /// - **newtype_struct**
@ -823,14 +823,15 @@ where
/// - **newtype_variant** /// - **newtype_variant**
/// - For example the `E::N` in `enum E { N(u8) }`. /// - For example the `E::N` in `enum E { N(u8) }`.
/// - **seq** /// - **seq**
/// - A variably sized heterogeneous sequence of values, for example `Vec<T>` or /// - A variably sized heterogeneous sequence of values, for example `Vec<T>`
/// `HashSet<T>`. When serializing, the length may or may not be known before /// or `HashSet<T>`. When serializing, the length may or may not be known
/// iterating through all the data. When deserializing, the length is determined /// before iterating through all the data. When deserializing, the length
/// by looking at the serialized data. /// is determined by looking at the serialized data.
/// - **tuple** /// - **tuple**
/// - A statically sized heterogeneous sequence of values for which the length /// - A statically sized heterogeneous sequence of values for which the
/// will be known at deserialization time without looking at the serialized /// length will be known at deserialization time without looking at the
/// data, for example `(u8,)` or `(String, u64, Vec<T>)` or `[u64; 10]`. /// serialized data, for example `(u8,)` or `(String, u64, Vec<T>)` or
/// `[u64; 10]`.
/// - **tuple_struct** /// - **tuple_struct**
/// - A named tuple, for example `struct Rgb(u8, u8, u8)`. /// - A named tuple, for example `struct Rgb(u8, u8, u8)`.
/// - **tuple_variant** /// - **tuple_variant**
@ -838,9 +839,9 @@ where
/// - **map** /// - **map**
/// - A heterogeneous key-value pairing, for example `BTreeMap<K, V>`. /// - A heterogeneous key-value pairing, for example `BTreeMap<K, V>`.
/// - **struct** /// - **struct**
/// - A heterogeneous key-value pairing in which the keys are strings and will be /// - A heterogeneous key-value pairing in which the keys are strings and
/// known at deserialization time without looking at the serialized data, for /// will be known at deserialization time without looking at the serialized
/// example `struct S { r: u8, g: u8, b: u8 }`. /// data, for example `struct S { r: u8, g: u8, b: u8 }`.
/// - **struct_variant** /// - **struct_variant**
/// - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`. /// - 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 /// type it sees in the input. JSON uses this approach when deserializing
/// `serde_json::Value` which is an enum that can represent any JSON /// `serde_json::Value` which is an enum that can represent any JSON
/// document. Without knowing what is in a JSON document, we can deserialize /// 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 /// 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. /// Bincode need to be told what is in the input in order to deserialize it.
@ -865,10 +867,11 @@ where
/// `Deserializer::deserialize_any`. /// `Deserializer::deserialize_any`.
/// ///
/// When implementing `Deserialize`, you should avoid relying on /// When implementing `Deserialize`, you should avoid relying on
/// `Deserializer::deserialize_any` unless you need to be told by the Deserializer /// `Deserializer::deserialize_any` unless you need to be told by the
/// what type is in the input. Know that relying on `Deserializer::deserialize_any` /// Deserializer what type is in the input. Know that relying on
/// means your data type will be able to deserialize from self-describing /// `Deserializer::deserialize_any` means your data type will be able to
/// formats only, ruling out Bincode and many others. /// deserialize from self-describing formats only, ruling out Bincode and many
/// others.
/// ///
/// [Serde data model]: https://serde.rs/data-model.html /// [Serde data model]: https://serde.rs/data-model.html
/// ///

View File

@ -832,8 +832,8 @@ mod content {
} }
impl<'de, T> TaggedContentVisitor<'de, T> { impl<'de, T> TaggedContentVisitor<'de, T> {
/// Visitor for the content of an internally tagged enum with the given tag /// Visitor for the content of an internally tagged enum with the given
/// name. /// tag name.
pub fn new(name: &'static str) -> Self { pub fn new(name: &'static str) -> Self {
TaggedContentVisitor { TaggedContentVisitor {
tag_name: name, tag_name: name,
@ -1075,8 +1075,8 @@ mod content {
Ok(value) Ok(value)
} }
/// Used when deserializing an internally tagged enum because the content will /// Used when deserializing an internally tagged enum because the content
/// be used exactly once. /// will be used exactly once.
impl<'de, E> Deserializer<'de> for ContentDeserializer<'de, E> impl<'de, E> Deserializer<'de> for ContentDeserializer<'de, E>
where where
E: de::Error, E: de::Error,
@ -1790,8 +1790,8 @@ mod content {
Ok(value) Ok(value)
} }
/// Used when deserializing an untagged enum because the content may need to be /// Used when deserializing an untagged enum because the content may need
/// used more than once. /// to be used more than once.
impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E> impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
where where
E: de::Error, E: de::Error,

View File

@ -219,7 +219,7 @@ pub trait Serialize {
/// information about how to implement this method. /// information about how to implement this method.
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeStruct}; /// use serde::ser::{Serialize, SerializeStruct, Serializer};
/// ///
/// struct Person { /// struct Person {
/// name: String, /// name: String,
@ -273,16 +273,16 @@ pub trait Serialize {
/// - When serializing, all strings are handled equally. When deserializing, /// - When serializing, all strings are handled equally. When deserializing,
/// there are three flavors of strings: transient, owned, and borrowed. /// there are three flavors of strings: transient, owned, and borrowed.
/// - **byte array** - \[u8\] /// - **byte array** - \[u8\]
/// - Similar to strings, during deserialization byte arrays can be transient, /// - Similar to strings, during deserialization byte arrays can be
/// owned, or borrowed. /// transient, owned, or borrowed.
/// - **option** /// - **option**
/// - Either none or some value. /// - Either none or some value.
/// - **unit** /// - **unit**
/// - The type of `()` in Rust. It represents an anonymous value containing no /// - The type of `()` in Rust. It represents an anonymous value containing
/// data. /// no data.
/// - **unit_struct** /// - **unit_struct**
/// - For example `struct Unit` or `PhantomData<T>`. It represents a named value /// - For example `struct Unit` or `PhantomData<T>`. It represents a named
/// containing no data. /// value containing no data.
/// - **unit_variant** /// - **unit_variant**
/// - For example the `E::A` and `E::B` in `enum E { A, B }`. /// - For example the `E::A` and `E::B` in `enum E { A, B }`.
/// - **newtype_struct** /// - **newtype_struct**
@ -290,14 +290,15 @@ pub trait Serialize {
/// - **newtype_variant** /// - **newtype_variant**
/// - For example the `E::N` in `enum E { N(u8) }`. /// - For example the `E::N` in `enum E { N(u8) }`.
/// - **seq** /// - **seq**
/// - A variably sized heterogeneous sequence of values, for example `Vec<T>` or /// - A variably sized heterogeneous sequence of values, for example
/// `HashSet<T>`. When serializing, the length may or may not be known before /// `Vec<T>` or `HashSet<T>`. When serializing, the length may or may not
/// iterating through all the data. When deserializing, the length is determined /// be known before iterating through all the data. When deserializing,
/// by looking at the serialized data. /// the length is determined by looking at the serialized data.
/// - **tuple** /// - **tuple**
/// - A statically sized heterogeneous sequence of values for which the length /// - A statically sized heterogeneous sequence of values for which the
/// will be known at deserialization time without looking at the serialized /// length will be known at deserialization time without looking at the
/// data, for example `(u8,)` or `(String, u64, Vec<T>)` or `[u64; 10]`. /// serialized data, for example `(u8,)` or `(String, u64, Vec<T>)` or
/// `[u64; 10]`.
/// - **tuple_struct** /// - **tuple_struct**
/// - A named tuple, for example `struct Rgb(u8, u8, u8)`. /// - A named tuple, for example `struct Rgb(u8, u8, u8)`.
/// - **tuple_variant** /// - **tuple_variant**
@ -305,9 +306,9 @@ pub trait Serialize {
/// - **map** /// - **map**
/// - A heterogeneous key-value pairing, for example `BTreeMap<K, V>`. /// - A heterogeneous key-value pairing, for example `BTreeMap<K, V>`.
/// - **struct** /// - **struct**
/// - A heterogeneous key-value pairing in which the keys are strings and will be /// - A heterogeneous key-value pairing in which the keys are strings and
/// known at deserialization time without looking at the serialized data, for /// will be known at deserialization time without looking at the
/// example `struct S { r: u8, g: u8, b: u8 }`. /// serialized data, for example `struct S { r: u8, g: u8, b: u8 }`.
/// - **struct_variant** /// - **struct_variant**
/// - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`. /// - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`.
/// ///
@ -1110,7 +1111,7 @@ pub trait Serializer: Sized {
/// ``` /// ```
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeTuple}; /// use serde::ser::{Serialize, SerializeTuple, Serializer};
/// ///
/// const VRAM_SIZE: usize = 386; /// const VRAM_SIZE: usize = 386;
/// struct Vram([u16; VRAM_SIZE]); /// struct Vram([u16; VRAM_SIZE]);
@ -1138,7 +1139,7 @@ pub trait Serializer: Sized {
/// of data fields that will be serialized. /// of data fields that will be serialized.
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeTupleStruct}; /// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
/// ///
/// struct Rgb(u8, u8, u8); /// 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. /// and the `len` is the number of data fields that will be serialized.
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeTupleVariant}; /// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
/// ///
/// enum E { /// enum E {
/// T(u8, u8), /// T(u8, u8),
@ -1264,7 +1265,7 @@ pub trait Serializer: Sized {
/// data fields that will be serialized. /// data fields that will be serialized.
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeStruct}; /// use serde::ser::{Serialize, SerializeStruct, Serializer};
/// ///
/// struct Rgb { /// struct Rgb {
/// r: u8, /// r: u8,
@ -1300,10 +1301,10 @@ pub trait Serializer: Sized {
/// and the `len` is the number of data fields that will be serialized. /// and the `len` is the number of data fields that will be serialized.
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeStructVariant}; /// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
/// ///
/// enum E { /// enum E {
/// S { r: u8, g: u8, b: u8 } /// S { r: u8, g: u8, b: u8 },
/// } /// }
/// ///
/// impl Serialize for E { /// impl Serialize for E {
@ -1312,7 +1313,11 @@ pub trait Serializer: Sized {
/// S: Serializer, /// S: Serializer,
/// { /// {
/// match *self { /// 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)?; /// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
/// sv.serialize_field("r", r)?; /// sv.serialize_field("r", r)?;
/// sv.serialize_field("g", g)?; /// sv.serialize_field("g", g)?;
@ -1375,8 +1380,8 @@ pub trait Serializer: Sized {
/// method. /// method.
/// ///
/// ```rust /// ```rust
/// use std::collections::BTreeSet;
/// use serde::{Serialize, Serializer}; /// use serde::{Serialize, Serializer};
/// use std::collections::BTreeSet;
/// ///
/// struct MapToUnit { /// struct MapToUnit {
/// keys: BTreeSet<i32>, /// keys: BTreeSet<i32>,
@ -1704,7 +1709,7 @@ pub trait SerializeTuple {
/// # Example use /// # Example use
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeTupleStruct}; /// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
/// ///
/// struct Rgb(u8, u8, u8); /// struct Rgb(u8, u8, u8);
/// ///
@ -1749,7 +1754,7 @@ pub trait SerializeTupleStruct {
/// # Example use /// # Example use
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeTupleVariant}; /// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
/// ///
/// enum E { /// enum E {
/// T(u8, u8), /// T(u8, u8),
@ -1918,7 +1923,7 @@ pub trait SerializeMap {
/// # Example use /// # Example use
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeStruct}; /// use serde::ser::{Serialize, SerializeStruct, Serializer};
/// ///
/// struct Rgb { /// struct Rgb {
/// r: u8, /// r: u8,
@ -1978,10 +1983,10 @@ pub trait SerializeStruct {
/// # Example use /// # Example use
/// ///
/// ```rust /// ```rust
/// use serde::ser::{Serialize, Serializer, SerializeStructVariant}; /// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
/// ///
/// enum E { /// enum E {
/// S { r: u8, g: u8, b: u8 } /// S { r: u8, g: u8, b: u8 },
/// } /// }
/// ///
/// impl Serialize for E { /// impl Serialize for E {
@ -1990,7 +1995,11 @@ pub trait SerializeStruct {
/// S: Serializer, /// S: Serializer,
/// { /// {
/// match *self { /// 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)?; /// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
/// sv.serialize_field("r", r)?; /// sv.serialize_field("r", r)?;
/// sv.serialize_field("g", g)?; /// sv.serialize_field("g", g)?;

View File

@ -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 // Puts the given bound on any generic type parameters that are used in fields
// for which filter returns true. // 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> { // struct S<'b, A, B: 'b, C> {
// a: A, // a: A,

View File

@ -837,7 +837,8 @@ fn deserialize_newtype_struct(
#[cfg(feature = "deserialize_in_place")] #[cfg(feature = "deserialize_in_place")]
fn deserialize_newtype_struct_in_place(params: &Parameters, field: &Field) -> TokenStream { 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()); assert!(field.attrs.deserialize_with().is_none());
let delife = params.borrowed.de_lifetime(); let delife = params.borrowed.de_lifetime();
@ -941,8 +942,8 @@ fn deserialize_struct(
quote!(mut __seq) quote!(mut __seq)
}; };
// untagged struct variants do not get a visit_seq method. The same applies to structs that // untagged struct variants do not get a visit_seq method. The same applies to
// only have a map representation. // structs that only have a map representation.
let visit_seq = match *untagged { let visit_seq = match *untagged {
Untagged::No if !cattrs.has_flatten() => Some(quote! { Untagged::No if !cattrs.has_flatten() => Some(quote! {
#[inline] #[inline]
@ -2547,7 +2548,8 @@ fn deserialize_map_in_place(
.map(|(i, field)| (field, field_i(i))) .map(|(i, field)| (field, field_i(i)))
.collect(); .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 let let_flags = fields_names
.iter() .iter()
.filter(|&&(field, _)| !field.attrs.skip_deserializing()) .filter(|&&(field, _)| !field.attrs.skip_deserializing())

View File

@ -989,9 +989,9 @@ impl Field {
} }
} }
// Is skip_deserializing, initialize the field to Default::default() unless a different // Is skip_deserializing, initialize the field to Default::default() unless a
// default is specified by `#[serde(default = "...")]` on ourselves or our container (e.g. // different default is specified by `#[serde(default = "...")]` on
// the struct we are in). // ourselves or our container (e.g. the struct we are in).
if let Default::None = *container_default { if let Default::None = *container_default {
if skip_deserializing.0.value.is_some() { if skip_deserializing.0.value.is_some() {
default.set_if_none(Default::Default); default.set_if_none(Default::Default);

View File

@ -22,13 +22,16 @@ pub enum RenameRule {
LowerCase, LowerCase,
/// Rename direct children to "UPPERCASE" style. /// Rename direct children to "UPPERCASE" style.
UPPERCASE, 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, PascalCase,
/// Rename direct children to "camelCase" style. /// Rename direct children to "camelCase" style.
CamelCase, 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, 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, ScreamingSnakeCase,
/// Rename direct children to "kebab-case" style. /// Rename direct children to "kebab-case" style.
KebabCase, KebabCase,

View File

@ -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 /// ```rust
/// # #[macro_use] /// # #[macro_use]

View File

@ -19,7 +19,7 @@ pub struct Compact<T: ?Sized>(T);
/// extern crate serde_test; /// extern crate serde_test;
/// ///
/// use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// use serde_test::{Configure, Token, assert_tokens}; /// use serde_test::{assert_tokens, Configure, Token};
/// ///
/// #[derive(Debug, PartialEq)] /// #[derive(Debug, PartialEq)]
/// struct Example(u8, u8); /// struct Example(u8, u8);
@ -67,12 +67,7 @@ pub struct Compact<T: ?Sized>(T);
/// Token::TupleEnd, /// Token::TupleEnd,
/// ], /// ],
/// ); /// );
/// assert_tokens( /// assert_tokens(&Example(1, 0).readable(), &[Token::Str("1.0")]);
/// &Example(1, 0).readable(),
/// &[
/// Token::Str("1.0"),
/// ],
/// );
/// } /// }
/// ``` /// ```
pub trait Configure { pub trait Configure {

View File

@ -11,7 +11,8 @@ use serde::{ser, Serialize};
use error::Error; use error::Error;
use token::Token; 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)] #[derive(Debug)]
pub struct Serializer<'a> { pub struct Serializer<'a> {
tokens: &'a [Token], tokens: &'a [Token],