Set all doc tests to 2018 edition
This commit is contained in:
parent
0b667c88fa
commit
11cc7014b3
@ -8,7 +8,7 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
|
||||
/// any type, except that it does not store any information about the data that
|
||||
/// gets deserialized.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use std::fmt;
|
||||
/// use std::marker::PhantomData;
|
||||
///
|
||||
@ -21,7 +21,7 @@ use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
|
||||
/// ///
|
||||
/// /// For example to deserialize only the element at index 3:
|
||||
/// ///
|
||||
/// /// ```rust
|
||||
/// /// ```
|
||||
/// /// NthElement::new(3).deserialize(deserializer)
|
||||
/// /// ```
|
||||
/// pub struct NthElement<T> {
|
||||
|
@ -153,7 +153,7 @@ macro_rules! declare_error_trait {
|
||||
///
|
||||
/// The message should not be capitalized and should not end with a period.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::str::FromStr;
|
||||
/// #
|
||||
/// # struct IpAddr;
|
||||
@ -298,7 +298,7 @@ declare_error_trait!(Error: Sized + Debug + Display);
|
||||
/// This is used as an argument to the `invalid_type`, `invalid_value`, and
|
||||
/// `invalid_length` methods of the `Error` trait to build error messages.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::fmt;
|
||||
/// #
|
||||
/// # use serde::de::{self, Unexpected, Visitor};
|
||||
@ -423,7 +423,7 @@ impl<'a> fmt::Display for Unexpected<'a> {
|
||||
/// Within the context of a `Visitor` implementation, the `Visitor` itself
|
||||
/// (`&self`) is an implementation of this trait.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::fmt;
|
||||
/// #
|
||||
/// # use serde::de::{self, Unexpected, Visitor};
|
||||
@ -448,7 +448,7 @@ impl<'a> fmt::Display for Unexpected<'a> {
|
||||
///
|
||||
/// Outside of a `Visitor`, `&"..."` can be used.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::de::{self, Unexpected};
|
||||
/// #
|
||||
/// # fn example<E>() -> Result<(), E>
|
||||
@ -569,7 +569,7 @@ pub trait Deserialize<'de>: Sized {
|
||||
/// from the input string, but a `from_reader` function may only deserialize
|
||||
/// owned data.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::de::{Deserialize, DeserializeOwned};
|
||||
/// # use std::io::{Read, Result};
|
||||
/// #
|
||||
@ -608,7 +608,7 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
|
||||
///
|
||||
/// The canonical API for stateless deserialization looks like this:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Deserialize;
|
||||
/// #
|
||||
/// # enum Error {}
|
||||
@ -622,7 +622,7 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
|
||||
/// Adjusting an API like this to support stateful deserialization is a matter
|
||||
/// of accepting a seed as input:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::de::DeserializeSeed;
|
||||
/// #
|
||||
/// # enum Error {}
|
||||
@ -655,7 +655,7 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
|
||||
/// into it. This requires stateful deserialization using the `DeserializeSeed`
|
||||
/// trait.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use std::fmt;
|
||||
/// use std::marker::PhantomData;
|
||||
///
|
||||
@ -1145,7 +1145,7 @@ pub trait Deserializer<'de>: Sized {
|
||||
/// human-readable one and binary formats like Bincode will prefer the
|
||||
/// compact one.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use std::ops::Add;
|
||||
/// # use std::str::FromStr;
|
||||
/// #
|
||||
@ -1222,7 +1222,7 @@ pub trait Deserializer<'de>: Sized {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::fmt;
|
||||
/// #
|
||||
/// # use serde::de::{self, Unexpected, Visitor};
|
||||
@ -1263,7 +1263,7 @@ pub trait Visitor<'de>: Sized {
|
||||
/// "an integer between 0 and 64". The message should not be capitalized and
|
||||
/// should not end with a period.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::fmt;
|
||||
/// #
|
||||
/// # struct S {
|
||||
@ -2004,7 +2004,7 @@ pub trait VariantAccess<'de>: Sized {
|
||||
/// If the data contains a different type of variant, the following
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
@ -2044,7 +2044,7 @@ pub trait VariantAccess<'de>: Sized {
|
||||
/// If the data contains a different type of variant, the following
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
@ -2100,7 +2100,7 @@ pub trait VariantAccess<'de>: Sized {
|
||||
/// If the data contains a different type of variant, the following
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
@ -2147,7 +2147,7 @@ pub trait VariantAccess<'de>: Sized {
|
||||
/// If the data contains a different type of variant, the following
|
||||
/// `invalid_type` error should be constructed:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||
/// #
|
||||
/// # struct X;
|
||||
@ -2207,7 +2207,7 @@ pub trait VariantAccess<'de>: Sized {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use std::str::FromStr;
|
||||
/// use serde::Deserialize;
|
||||
/// use serde::de::{value, IntoDeserializer};
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Building blocks for deserializing basic values using the `IntoDeserializer`
|
||||
//! trait.
|
||||
//!
|
||||
//! ```rust
|
||||
//! ```edition2018
|
||||
//! use std::str::FromStr;
|
||||
//! use serde::Deserialize;
|
||||
//! use serde::de::{value, IntoDeserializer};
|
||||
|
@ -9,7 +9,7 @@
|
||||
/// do not need to bother with this macro and may assume support for 128-bit
|
||||
/// integers.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::private::ser::Error;
|
||||
/// #
|
||||
/// # struct MySerializer;
|
||||
@ -50,7 +50,7 @@
|
||||
/// When Serde is built with support for 128-bit integers, this macro expands
|
||||
/// transparently into just the input tokens.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// macro_rules! serde_if_integer128 {
|
||||
/// ($($tt:tt)*) => {
|
||||
/// $($tt)*
|
||||
@ -61,7 +61,7 @@
|
||||
/// When built without support for 128-bit integers, this macro expands to
|
||||
/// nothing.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// macro_rules! serde_if_integer128 {
|
||||
/// ($($tt:tt)*) => {};
|
||||
/// }
|
||||
|
@ -11,7 +11,7 @@
|
||||
/// input. This requires repetitive implementations of all the [`Deserializer`]
|
||||
/// trait methods.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::forward_to_deserialize_any;
|
||||
/// # use serde::de::{value, Deserializer, Visitor};
|
||||
/// #
|
||||
@ -47,7 +47,7 @@
|
||||
/// methods so that they forward directly to [`Deserializer::deserialize_any`].
|
||||
/// You can choose which methods to forward.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::forward_to_deserialize_any;
|
||||
/// # use serde::de::{value, Deserializer, Visitor};
|
||||
/// #
|
||||
@ -78,7 +78,7 @@
|
||||
/// called `V`. A different type parameter and a different lifetime can be
|
||||
/// specified explicitly if necessary.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::marker::PhantomData;
|
||||
/// #
|
||||
/// # use serde::forward_to_deserialize_any;
|
||||
|
@ -15,7 +15,7 @@ use ser::{
|
||||
/// [`SerializeTuple`], [`SerializeTupleStruct`], [`SerializeTupleVariant`],
|
||||
/// [`SerializeMap`], [`SerializeStruct`], and [`SerializeStructVariant`].
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::ser::{Serializer, Impossible};
|
||||
/// # use serde::private::ser::Error;
|
||||
/// #
|
||||
|
@ -137,7 +137,7 @@ macro_rules! declare_error_trait {
|
||||
/// For example, a filesystem [`Path`] may refuse to serialize
|
||||
/// itself if it contains invalid UTF-8 data.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # struct Path;
|
||||
/// #
|
||||
/// # impl Path {
|
||||
@ -210,7 +210,7 @@ pub trait Serialize {
|
||||
/// See the [Implementing `Serialize`] section of the manual for more
|
||||
/// information about how to implement this method.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||
///
|
||||
/// struct Person {
|
||||
@ -377,7 +377,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize a `bool` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -399,7 +399,7 @@ pub trait Serializer: Sized {
|
||||
/// reasonable implementation would be to cast the value to `i64` and
|
||||
/// forward to `serialize_i64`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -421,7 +421,7 @@ pub trait Serializer: Sized {
|
||||
/// reasonable implementation would be to cast the value to `i64` and
|
||||
/// forward to `serialize_i64`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -443,7 +443,7 @@ pub trait Serializer: Sized {
|
||||
/// reasonable implementation would be to cast the value to `i64` and
|
||||
/// forward to `serialize_i64`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -461,7 +461,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize an `i64` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -480,7 +480,7 @@ pub trait Serializer: Sized {
|
||||
serde_if_integer128! {
|
||||
/// Serialize an `i128` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -509,7 +509,7 @@ pub trait Serializer: Sized {
|
||||
/// reasonable implementation would be to cast the value to `u64` and
|
||||
/// forward to `serialize_u64`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -531,7 +531,7 @@ pub trait Serializer: Sized {
|
||||
/// reasonable implementation would be to cast the value to `u64` and
|
||||
/// forward to `serialize_u64`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -553,7 +553,7 @@ pub trait Serializer: Sized {
|
||||
/// reasonable implementation would be to cast the value to `u64` and
|
||||
/// forward to `serialize_u64`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -571,7 +571,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize a `u64` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -590,7 +590,7 @@ pub trait Serializer: Sized {
|
||||
serde_if_integer128! {
|
||||
/// Serialize a `u128` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -619,7 +619,7 @@ pub trait Serializer: Sized {
|
||||
/// reasonable implementation would be to cast the value to `f64` and
|
||||
/// forward to `serialize_f64`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -637,7 +637,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize an `f64` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -658,7 +658,7 @@ pub trait Serializer: Sized {
|
||||
/// If the format does not support characters, it is reasonable to serialize
|
||||
/// it as a single element `str` or a `u32`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -676,7 +676,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize a `&str`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -700,7 +700,7 @@ pub trait Serializer: Sized {
|
||||
/// `serialize_seq`. If forwarded, the implementation looks usually just
|
||||
/// like this:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::ser::{Serializer, SerializeSeq};
|
||||
/// # use serde::private::ser::Error;
|
||||
/// #
|
||||
@ -729,7 +729,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize a [`None`] value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::{Serialize, Serializer};
|
||||
/// #
|
||||
/// # enum Option<T> {
|
||||
@ -762,7 +762,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize a [`Some(T)`] value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::{Serialize, Serializer};
|
||||
/// #
|
||||
/// # enum Option<T> {
|
||||
@ -797,7 +797,7 @@ pub trait Serializer: Sized {
|
||||
|
||||
/// Serialize a `()` value.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use serde::Serializer;
|
||||
/// #
|
||||
/// # serde::__private_serialize!();
|
||||
@ -817,7 +817,7 @@ pub trait Serializer: Sized {
|
||||
///
|
||||
/// A reasonable implementation would be to forward to `serialize_unit`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::{Serialize, Serializer};
|
||||
///
|
||||
/// struct Nothing;
|
||||
@ -839,7 +839,7 @@ pub trait Serializer: Sized {
|
||||
/// this variant within the enum, and the `variant` is the name of the
|
||||
/// variant.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::{Serialize, Serializer};
|
||||
///
|
||||
/// enum E {
|
||||
@ -872,7 +872,7 @@ pub trait Serializer: Sized {
|
||||
/// wrappers around the data they contain. A reasonable implementation would
|
||||
/// be to forward to `value.serialize(self)`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::{Serialize, Serializer};
|
||||
///
|
||||
/// struct Millimeters(u8);
|
||||
@ -900,7 +900,7 @@ pub trait Serializer: Sized {
|
||||
/// this variant within the enum, and the `variant` is the name of the
|
||||
/// variant. The `value` is the data contained within this newtype variant.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::{Serialize, Serializer};
|
||||
///
|
||||
/// enum E {
|
||||
@ -938,7 +938,7 @@ pub trait Serializer: Sized {
|
||||
/// not be computable before the sequence is iterated. Some serializers only
|
||||
/// support sequences whose length is known up front.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::marker::PhantomData;
|
||||
/// #
|
||||
/// # struct Vec<T>(PhantomData<T>);
|
||||
@ -983,7 +983,7 @@ pub trait Serializer: Sized {
|
||||
/// This call must be followed by zero or more calls to `serialize_element`,
|
||||
/// then a call to `end`.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, Serializer, SerializeTuple};
|
||||
///
|
||||
/// # mod fool {
|
||||
@ -1013,7 +1013,7 @@ pub trait Serializer: Sized {
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeTuple, Serializer};
|
||||
///
|
||||
/// const VRAM_SIZE: usize = 386;
|
||||
@ -1041,7 +1041,7 @@ pub trait Serializer: Sized {
|
||||
/// The `name` is the name of the tuple struct and the `len` is the number
|
||||
/// of data fields that will be serialized.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
|
||||
///
|
||||
/// struct Rgb(u8, u8, u8);
|
||||
@ -1073,7 +1073,7 @@ pub trait Serializer: Sized {
|
||||
/// this variant within the enum, the `variant` is the name of the variant,
|
||||
/// and the `len` is the number of data fields that will be serialized.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
|
||||
///
|
||||
/// enum E {
|
||||
@ -1119,7 +1119,7 @@ pub trait Serializer: Sized {
|
||||
/// be computable before the map is iterated. Some serializers only support
|
||||
/// maps whose length is known up front.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::marker::PhantomData;
|
||||
/// #
|
||||
/// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
|
||||
@ -1167,7 +1167,7 @@ pub trait Serializer: Sized {
|
||||
/// The `name` is the name of the struct and the `len` is the number of
|
||||
/// data fields that will be serialized.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||
///
|
||||
/// struct Rgb {
|
||||
@ -1203,7 +1203,7 @@ pub trait Serializer: Sized {
|
||||
/// this variant within the enum, the `variant` is the name of the variant,
|
||||
/// and the `len` is the number of data fields that will be serialized.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
|
||||
///
|
||||
/// enum E {
|
||||
@ -1245,7 +1245,7 @@ pub trait Serializer: Sized {
|
||||
/// using [`serialize_seq`]. Implementors should not need to override this
|
||||
/// method.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::{Serialize, Serializer};
|
||||
///
|
||||
/// struct SecretlyOneHigher {
|
||||
@ -1282,7 +1282,7 @@ pub trait Serializer: Sized {
|
||||
/// using [`serialize_map`]. Implementors should not need to override this
|
||||
/// method.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::{Serialize, Serializer};
|
||||
/// use std::collections::BTreeSet;
|
||||
///
|
||||
@ -1322,7 +1322,7 @@ pub trait Serializer: Sized {
|
||||
/// delegates to [`serialize_str`]. Serializers are encouraged to provide a
|
||||
/// more efficient implementation if possible.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # struct DateTime;
|
||||
/// #
|
||||
/// # impl DateTime {
|
||||
@ -1363,7 +1363,7 @@ pub trait Serializer: Sized {
|
||||
/// of this method. If no more sensible behavior is possible, the
|
||||
/// implementation is expected to return an error.
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # struct DateTime;
|
||||
/// #
|
||||
/// # impl DateTime {
|
||||
@ -1398,7 +1398,7 @@ pub trait Serializer: Sized {
|
||||
/// human-readable one and binary formats like Bincode will prefer the
|
||||
/// compact one.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use std::fmt::{self, Display};
|
||||
/// #
|
||||
/// # struct Timestamp;
|
||||
@ -1447,7 +1447,7 @@ pub trait Serializer: Sized {
|
||||
///
|
||||
/// # Example use
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::marker::PhantomData;
|
||||
/// #
|
||||
/// # struct Vec<T>(PhantomData<T>);
|
||||
@ -1511,7 +1511,7 @@ pub trait SerializeSeq {
|
||||
///
|
||||
/// # Example use
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, Serializer, SerializeTuple};
|
||||
///
|
||||
/// # mod fool {
|
||||
@ -1541,7 +1541,7 @@ pub trait SerializeSeq {
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::marker::PhantomData;
|
||||
/// #
|
||||
/// # struct Array<T>(PhantomData<T>);
|
||||
@ -1611,7 +1611,7 @@ pub trait SerializeTuple {
|
||||
///
|
||||
/// # Example use
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
|
||||
///
|
||||
/// struct Rgb(u8, u8, u8);
|
||||
@ -1656,7 +1656,7 @@ pub trait SerializeTupleStruct {
|
||||
///
|
||||
/// # Example use
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
|
||||
///
|
||||
/// enum E {
|
||||
@ -1714,7 +1714,7 @@ pub trait SerializeTupleVariant {
|
||||
///
|
||||
/// # Example use
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// # use std::marker::PhantomData;
|
||||
/// #
|
||||
/// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
|
||||
@ -1825,7 +1825,7 @@ pub trait SerializeMap {
|
||||
///
|
||||
/// # Example use
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||
///
|
||||
/// struct Rgb {
|
||||
@ -1885,7 +1885,7 @@ pub trait SerializeStruct {
|
||||
///
|
||||
/// # Example use
|
||||
///
|
||||
/// ```rust
|
||||
/// ```edition2018
|
||||
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
|
||||
///
|
||||
/// enum E {
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! This crate provides Serde's two derive macros.
|
||||
//!
|
||||
//! ```rust
|
||||
//! ```edition2018
|
||||
//! # use serde_derive::{Serialize, Deserialize};
|
||||
//! #
|
||||
//! #[derive(Serialize, Deserialize)]
|
||||
|
@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Display};
|
||||
pub enum Token {
|
||||
/// A serialized `bool`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&true, &[Token::Bool(true)]);
|
||||
@ -13,7 +13,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `i8`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0i8, &[Token::I8(0)]);
|
||||
@ -22,7 +22,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `i16`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0i16, &[Token::I16(0)]);
|
||||
@ -31,7 +31,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `i32`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0i32, &[Token::I32(0)]);
|
||||
@ -40,7 +40,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `i64`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0i64, &[Token::I64(0)]);
|
||||
@ -49,7 +49,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `u8`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0u8, &[Token::U8(0)]);
|
||||
@ -58,7 +58,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `u16`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0u16, &[Token::U16(0)]);
|
||||
@ -67,7 +67,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `u32`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0u32, &[Token::U32(0)]);
|
||||
@ -76,7 +76,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `u64`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0u64, &[Token::U64(0)]);
|
||||
@ -85,7 +85,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `f32`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0f32, &[Token::F32(0.0)]);
|
||||
@ -94,7 +94,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `f64`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&0f64, &[Token::F64(0.0)]);
|
||||
@ -103,7 +103,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `char`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&'\n', &[Token::Char('\n')]);
|
||||
@ -112,7 +112,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `str`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// let s = String::from("transient");
|
||||
@ -122,7 +122,7 @@ pub enum Token {
|
||||
|
||||
/// A borrowed `str`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// let s: &str = "borrowed";
|
||||
@ -132,7 +132,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `String`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// let s = String::from("owned");
|
||||
@ -151,7 +151,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `Option<T>` containing none.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// let opt = None::<char>;
|
||||
@ -163,7 +163,7 @@ pub enum Token {
|
||||
///
|
||||
/// The tokens of the value follow after this header.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// let opt = Some('c');
|
||||
@ -176,7 +176,7 @@ pub enum Token {
|
||||
|
||||
/// A serialized `()`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// assert_tokens(&(), &[Token::Unit]);
|
||||
@ -271,7 +271,7 @@ pub enum Token {
|
||||
/// After this header are the elements of the sequence, followed by
|
||||
/// `SeqEnd`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// let vec = vec!['a', 'b', 'c'];
|
||||
@ -292,7 +292,7 @@ pub enum Token {
|
||||
///
|
||||
/// After this header are the elements of the tuple, followed by `TupleEnd`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// let tuple = ('a', 100);
|
||||
@ -372,7 +372,7 @@ pub enum Token {
|
||||
///
|
||||
/// After this header are the entries of the map, followed by `MapEnd`.
|
||||
///
|
||||
/// ```
|
||||
/// ```edition2018
|
||||
/// # use serde_test::{assert_tokens, Token};
|
||||
/// #
|
||||
/// use std::collections::BTreeMap;
|
||||
|
Loading…
Reference in New Issue
Block a user