Skip to content

Commit

Permalink
Merge pull request #2493 from dtolnay/docedition
Browse files Browse the repository at this point in the history
Update documentation example code to 2021 edition
  • Loading branch information
dtolnay committed Jul 6, 2023
2 parents ea071ae + 541603a commit 3a1f387
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 118 deletions.
2 changes: 1 addition & 1 deletion serde/src/de/ignored_any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use de::{
/// any type, except that it does not store any information about the data that
/// gets deserialized.
///
/// ```edition2018
/// ```edition2021
/// use std::fmt;
/// use std::marker::PhantomData;
///
Expand Down
32 changes: 16 additions & 16 deletions serde/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ macro_rules! declare_error_trait {
///
/// The message should not be capitalized and should not end with a period.
///
/// ```edition2018
/// ```edition2021
/// # use std::str::FromStr;
/// #
/// # struct IpAddr;
Expand Down Expand Up @@ -307,7 +307,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.
///
/// ```edition2018
/// ```edition2021
/// # use std::fmt;
/// #
/// # use serde::de::{self, Unexpected, Visitor};
Expand Down Expand Up @@ -432,7 +432,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.
///
/// ```edition2018
/// ```edition2021
/// # use std::fmt;
/// #
/// # use serde::de::{self, Unexpected, Visitor};
Expand All @@ -457,7 +457,7 @@ impl<'a> fmt::Display for Unexpected<'a> {
///
/// Outside of a `Visitor`, `&"..."` can be used.
///
/// ```edition2018
/// ```edition2021
/// # use serde::de::{self, Unexpected};
/// #
/// # fn example<E>() -> Result<(), E>
Expand Down Expand Up @@ -577,7 +577,7 @@ pub trait Deserialize<'de>: Sized {
/// from the input string, but a `from_reader` function may only deserialize
/// owned data.
///
/// ```edition2018
/// ```edition2021
/// # use serde::de::{Deserialize, DeserializeOwned};
/// # use std::io::{Read, Result};
/// #
Expand Down Expand Up @@ -616,7 +616,7 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
///
/// The canonical API for stateless deserialization looks like this:
///
/// ```edition2018
/// ```edition2021
/// # use serde::Deserialize;
/// #
/// # enum Error {}
Expand All @@ -630,7 +630,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:
///
/// ```edition2018
/// ```edition2021
/// # use serde::de::DeserializeSeed;
/// #
/// # enum Error {}
Expand Down Expand Up @@ -663,7 +663,7 @@ impl<T> DeserializeOwned for T where T: for<'de> Deserialize<'de> {}
/// into it. This requires stateful deserialization using the `DeserializeSeed`
/// trait.
///
/// ```edition2018
/// ```edition2021
/// use std::fmt;
/// use std::marker::PhantomData;
///
Expand Down Expand Up @@ -1158,7 +1158,7 @@ pub trait Deserializer<'de>: Sized {
/// human-readable one and binary formats like Postcard will prefer the
/// compact one.
///
/// ```edition2018
/// ```edition2021
/// # use std::ops::Add;
/// # use std::str::FromStr;
/// #
Expand Down Expand Up @@ -1249,7 +1249,7 @@ pub trait Deserializer<'de>: Sized {
///
/// # Example
///
/// ```edition2018
/// ```edition2021
/// # use std::fmt;
/// #
/// # use serde::de::{self, Unexpected, Visitor};
Expand Down Expand Up @@ -1290,7 +1290,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.
///
/// ```edition2018
/// ```edition2021
/// # use std::fmt;
/// #
/// # struct S {
Expand Down Expand Up @@ -2035,7 +2035,7 @@ pub trait VariantAccess<'de>: Sized {
/// If the data contains a different type of variant, the following
/// `invalid_type` error should be constructed:
///
/// ```edition2018
/// ```edition2021
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
/// #
/// # struct X;
Expand Down Expand Up @@ -2075,7 +2075,7 @@ pub trait VariantAccess<'de>: Sized {
/// If the data contains a different type of variant, the following
/// `invalid_type` error should be constructed:
///
/// ```edition2018
/// ```edition2021
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
/// #
/// # struct X;
Expand Down Expand Up @@ -2131,7 +2131,7 @@ pub trait VariantAccess<'de>: Sized {
/// If the data contains a different type of variant, the following
/// `invalid_type` error should be constructed:
///
/// ```edition2018
/// ```edition2021
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
/// #
/// # struct X;
Expand Down Expand Up @@ -2178,7 +2178,7 @@ pub trait VariantAccess<'de>: Sized {
/// If the data contains a different type of variant, the following
/// `invalid_type` error should be constructed:
///
/// ```edition2018
/// ```edition2021
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
/// #
/// # struct X;
Expand Down Expand Up @@ -2238,7 +2238,7 @@ pub trait VariantAccess<'de>: Sized {
///
/// # Example
///
/// ```edition2018
/// ```edition2021
/// use std::str::FromStr;
/// use serde::Deserialize;
/// use serde::de::{value, IntoDeserializer};
Expand Down
2 changes: 1 addition & 1 deletion serde/src/de/value.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Building blocks for deserializing basic values using the `IntoDeserializer`
//! trait.
//!
//! ```edition2018
//! ```edition2021
//! use std::str::FromStr;
//! use serde::Deserialize;
//! use serde::de::{value, IntoDeserializer};
Expand Down
6 changes: 3 additions & 3 deletions serde/src/integer128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// or do not target platforms that lack 128-bit integers, do not need to
/// bother with this macro and may assume support for 128-bit integers.
///
/// ```edition2018
/// ```edition2021
/// # use serde::__private::doc::Error;
/// #
/// # struct MySerializer;
Expand Down Expand Up @@ -50,7 +50,7 @@
/// When Serde is built with support for 128-bit integers, this macro expands
/// transparently into just the input tokens.
///
/// ```edition2018
/// ```edition2021
/// macro_rules! serde_if_integer128 {
/// ($($tt:tt)*) => {
/// $($tt)*
Expand All @@ -61,7 +61,7 @@
/// When built without support for 128-bit integers, this macro expands to
/// nothing.
///
/// ```edition2018
/// ```edition2021
/// macro_rules! serde_if_integer128 {
/// ($($tt:tt)*) => {};
/// }
Expand Down
6 changes: 3 additions & 3 deletions serde/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// input. This requires repetitive implementations of all the [`Deserializer`]
/// trait methods.
///
/// ```edition2018
/// ```edition2021
/// # use serde::forward_to_deserialize_any;
/// # use serde::de::{value, Deserializer, Visitor};
/// #
Expand Down Expand Up @@ -47,7 +47,7 @@
/// methods so that they forward directly to [`Deserializer::deserialize_any`].
/// You can choose which methods to forward.
///
/// ```edition2018
/// ```edition2021
/// # use serde::forward_to_deserialize_any;
/// # use serde::de::{value, Deserializer, Visitor};
/// #
Expand Down Expand Up @@ -78,7 +78,7 @@
/// called `V`. A different type parameter and a different lifetime can be
/// specified explicitly if necessary.
///
/// ```edition2018
/// ```edition2021
/// # use std::marker::PhantomData;
/// #
/// # use serde::forward_to_deserialize_any;
Expand Down
2 changes: 1 addition & 1 deletion serde/src/ser/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ macro_rules! fmt_primitives {
};
}

/// ```edition2018
/// ```edition2021
/// use serde::Serialize;
/// use std::fmt::{self, Display};
///
Expand Down
2 changes: 1 addition & 1 deletion serde/src/ser/impossible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ser::{
/// [`SerializeTuple`], [`SerializeTupleStruct`], [`SerializeTupleVariant`],
/// [`SerializeMap`], [`SerializeStruct`], and [`SerializeStructVariant`].
///
/// ```edition2018
/// ```edition2021
/// # use serde::ser::{Serializer, Impossible};
/// # use serde::__private::doc::Error;
/// #
Expand Down
Loading

0 comments on commit 3a1f387

Please sign in to comment.