mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-07-15 16:05:47 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fea4e8e5b6 | |||
| 1df8b5785b | |||
| 981a75d7c9 | |||
| 11cc7014b3 | |||
| 0b667c88fa | |||
| 054ab1adaf | |||
| f1f8386f2e | |||
| ba8c3970b0 | |||
| 2f36b26a5c | |||
| 9b4edb3a1d | |||
| b8adc5ffa2 | |||
| bd90cafda7 | |||
| 6d43a08a1d | |||
| e71b8598ae | |||
| 95d0f437e3 | |||
| c95ee3968a | |||
| c22dd4ada5 | |||
| 727a40fc5a | |||
| ce84a5f1d3 | |||
| e6fda1c410 | |||
| 294dccc5be | |||
| da346a8878 | |||
| c5ccb995ad | |||
| 05ab569a80 | |||
| ab3f4971f0 | |||
| 47e238aa13 | |||
| e49b6c708b | |||
| eb7250792b | |||
| 7e5066b878 | |||
| 889e17816f |
+9
-9
@@ -9,7 +9,7 @@ matrix:
|
|||||||
- cargo build --no-default-features
|
- cargo build --no-default-features
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_test"
|
- cd "${TRAVIS_BUILD_DIR}/serde_test"
|
||||||
- cargo build
|
- cargo build
|
||||||
- cargo test
|
- cargo test --features serde/derive,serde/rc
|
||||||
|
|
||||||
- rust: beta
|
- rust: beta
|
||||||
script:
|
script:
|
||||||
@@ -25,11 +25,11 @@ matrix:
|
|||||||
- cargo build --no-default-features
|
- cargo build --no-default-features
|
||||||
- cargo build --no-default-features --features alloc
|
- cargo build --no-default-features --features alloc
|
||||||
- cargo build --no-default-features --features rc,alloc
|
- cargo build --no-default-features --features rc,alloc
|
||||||
- cargo test --features rc,unstable
|
- cargo test --features derive,rc,unstable
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite/deps"
|
- cd "${TRAVIS_BUILD_DIR}/test_suite/deps"
|
||||||
- cargo build
|
- cargo build
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
||||||
- cargo test --features unstable
|
- cargo test --features compiletest,unstable
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite/no_std"
|
- cd "${TRAVIS_BUILD_DIR}/test_suite/no_std"
|
||||||
- cargo build
|
- cargo build
|
||||||
|
|
||||||
@@ -55,17 +55,17 @@ matrix:
|
|||||||
name: Clippy
|
name: Clippy
|
||||||
script:
|
script:
|
||||||
- rustup component add clippy-preview || travis_terminate 0
|
- rustup component add clippy-preview || travis_terminate 0
|
||||||
- cargo clippy -- -Dclippy
|
- cargo clippy -- -D clippy::all
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde"
|
- cd "${TRAVIS_BUILD_DIR}/serde"
|
||||||
- cargo clippy --features rc,unstable -- -Dclippy
|
- cargo clippy --features rc,unstable -- -D clippy::all
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_derive"
|
- cd "${TRAVIS_BUILD_DIR}/serde_derive"
|
||||||
- cargo clippy -- -Dclippy
|
- cargo clippy -- -D clippy::all
|
||||||
- cd "${TRAVIS_BUILD_DIR}/serde_test"
|
- cd "${TRAVIS_BUILD_DIR}/serde_test"
|
||||||
- cargo clippy -- -Dclippy
|
- cargo clippy -- -D clippy::all
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
- cd "${TRAVIS_BUILD_DIR}/test_suite"
|
||||||
- cargo clippy --features unstable -- -Dclippy
|
- cargo clippy --tests --features unstable -- -D clippy::all
|
||||||
- cd "${TRAVIS_BUILD_DIR}/test_suite/no_std"
|
- cd "${TRAVIS_BUILD_DIR}/test_suite/no_std"
|
||||||
- cargo clippy -- -Dclippy
|
- cargo clippy -- -D clippy::all
|
||||||
|
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
name: Emscripten
|
name: Emscripten
|
||||||
|
|||||||
+3
-3
@@ -23,7 +23,7 @@ for:
|
|||||||
- cargo build --no-default-features
|
- cargo build --no-default-features
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%\serde_test
|
- cd %APPVEYOR_BUILD_FOLDER%\serde_test
|
||||||
- cargo build
|
- cargo build
|
||||||
- cargo test
|
- cargo test --features serde/derive,serde/rc
|
||||||
|
|
||||||
- matrix:
|
- matrix:
|
||||||
only:
|
only:
|
||||||
@@ -34,8 +34,8 @@ for:
|
|||||||
- cargo build --no-default-features
|
- cargo build --no-default-features
|
||||||
- cargo build --no-default-features --features alloc
|
- cargo build --no-default-features --features alloc
|
||||||
- cargo build --no-default-features --features rc,alloc
|
- cargo build --no-default-features --features rc,alloc
|
||||||
- cargo test --features rc,unstable
|
- cargo test --features derive,rc,unstable
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%\test_suite\deps
|
- cd %APPVEYOR_BUILD_FOLDER%\test_suite\deps
|
||||||
- cargo build
|
- cargo build
|
||||||
- cd %APPVEYOR_BUILD_FOLDER%\test_suite
|
- cd %APPVEYOR_BUILD_FOLDER%\test_suite
|
||||||
- cargo test --features unstable
|
- cargo test --features compiletest,unstable
|
||||||
|
|||||||
+4
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.83" # remember to update html_root_url
|
version = "1.0.84" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
@@ -23,6 +23,9 @@ serde_derive = { version = "1.0", optional = true, path = "../serde_derive" }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||||
|
|
||||||
|
[package.metadata.playground]
|
||||||
|
features = ["derive", "rc"]
|
||||||
|
|
||||||
|
|
||||||
### FEATURES #################################################################
|
### FEATURES #################################################################
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
/// any type, except that it does not store any information about the data that
|
||||||
/// gets deserialized.
|
/// gets deserialized.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use std::fmt;
|
/// use std::fmt;
|
||||||
/// use std::marker::PhantomData;
|
/// 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:
|
/// /// For example to deserialize only the element at index 3:
|
||||||
/// ///
|
/// ///
|
||||||
/// /// ```rust
|
/// /// ```
|
||||||
/// /// NthElement::new(3).deserialize(deserializer)
|
/// /// NthElement::new(3).deserialize(deserializer)
|
||||||
/// /// ```
|
/// /// ```
|
||||||
/// pub struct NthElement<T> {
|
/// pub struct NthElement<T> {
|
||||||
|
|||||||
+19
-25
@@ -153,7 +153,7 @@ macro_rules! declare_error_trait {
|
|||||||
///
|
///
|
||||||
/// The message should not be capitalized and should not end with a period.
|
/// The message should not be capitalized and should not end with a period.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// #
|
/// #
|
||||||
/// # struct IpAddr;
|
/// # struct IpAddr;
|
||||||
@@ -173,7 +173,7 @@ macro_rules! declare_error_trait {
|
|||||||
/// where
|
/// where
|
||||||
/// D: Deserializer<'de>,
|
/// D: Deserializer<'de>,
|
||||||
/// {
|
/// {
|
||||||
/// let s = try!(String::deserialize(deserializer));
|
/// let s = String::deserialize(deserializer)?;
|
||||||
/// s.parse().map_err(de::Error::custom)
|
/// s.parse().map_err(de::Error::custom)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
@@ -298,7 +298,7 @@ declare_error_trait!(Error: Sized + Debug + Display);
|
|||||||
/// This is used as an argument to the `invalid_type`, `invalid_value`, and
|
/// This is used as an argument to the `invalid_type`, `invalid_value`, and
|
||||||
/// `invalid_length` methods of the `Error` trait to build error messages.
|
/// `invalid_length` methods of the `Error` trait to build error messages.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::fmt;
|
/// # use std::fmt;
|
||||||
/// #
|
/// #
|
||||||
/// # use serde::de::{self, Unexpected, Visitor};
|
/// # 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
|
/// Within the context of a `Visitor` implementation, the `Visitor` itself
|
||||||
/// (`&self`) is an implementation of this trait.
|
/// (`&self`) is an implementation of this trait.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::fmt;
|
/// # use std::fmt;
|
||||||
/// #
|
/// #
|
||||||
/// # use serde::de::{self, Unexpected, Visitor};
|
/// # use serde::de::{self, Unexpected, Visitor};
|
||||||
@@ -448,7 +448,7 @@ impl<'a> fmt::Display for Unexpected<'a> {
|
|||||||
///
|
///
|
||||||
/// Outside of a `Visitor`, `&"..."` can be used.
|
/// Outside of a `Visitor`, `&"..."` can be used.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::de::{self, Unexpected};
|
/// # use serde::de::{self, Unexpected};
|
||||||
/// #
|
/// #
|
||||||
/// # fn example<E>() -> Result<(), E>
|
/// # 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
|
/// from the input string, but a `from_reader` function may only deserialize
|
||||||
/// owned data.
|
/// owned data.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::de::{Deserialize, DeserializeOwned};
|
/// # use serde::de::{Deserialize, DeserializeOwned};
|
||||||
/// # use std::io::{Read, Result};
|
/// # 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:
|
/// The canonical API for stateless deserialization looks like this:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::Deserialize;
|
/// # use serde::Deserialize;
|
||||||
/// #
|
/// #
|
||||||
/// # enum Error {}
|
/// # 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
|
/// Adjusting an API like this to support stateful deserialization is a matter
|
||||||
/// of accepting a seed as input:
|
/// of accepting a seed as input:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::de::DeserializeSeed;
|
/// # use serde::de::DeserializeSeed;
|
||||||
/// #
|
/// #
|
||||||
/// # enum Error {}
|
/// # 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`
|
/// into it. This requires stateful deserialization using the `DeserializeSeed`
|
||||||
/// trait.
|
/// trait.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use std::fmt;
|
/// use std::fmt;
|
||||||
/// use std::marker::PhantomData;
|
/// use std::marker::PhantomData;
|
||||||
///
|
///
|
||||||
@@ -1145,7 +1145,7 @@ pub trait Deserializer<'de>: Sized {
|
|||||||
/// human-readable one and binary formats like Bincode will prefer the
|
/// human-readable one and binary formats like Bincode will prefer the
|
||||||
/// compact one.
|
/// compact one.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```edition2018
|
||||||
/// # use std::ops::Add;
|
/// # use std::ops::Add;
|
||||||
/// # use std::str::FromStr;
|
/// # use std::str::FromStr;
|
||||||
/// #
|
/// #
|
||||||
@@ -1222,7 +1222,7 @@ pub trait Deserializer<'de>: Sized {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::fmt;
|
/// # use std::fmt;
|
||||||
/// #
|
/// #
|
||||||
/// # use serde::de::{self, Unexpected, Visitor};
|
/// # 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
|
/// "an integer between 0 and 64". The message should not be capitalized and
|
||||||
/// should not end with a period.
|
/// should not end with a period.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::fmt;
|
/// # use std::fmt;
|
||||||
/// #
|
/// #
|
||||||
/// # struct S {
|
/// # struct S {
|
||||||
@@ -2004,7 +2004,7 @@ pub trait VariantAccess<'de>: Sized {
|
|||||||
/// If the data contains a different type of variant, the following
|
/// If the data contains a different type of variant, the following
|
||||||
/// `invalid_type` error should be constructed:
|
/// `invalid_type` error should be constructed:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||||
/// #
|
/// #
|
||||||
/// # struct X;
|
/// # struct X;
|
||||||
@@ -2044,7 +2044,7 @@ pub trait VariantAccess<'de>: Sized {
|
|||||||
/// If the data contains a different type of variant, the following
|
/// If the data contains a different type of variant, the following
|
||||||
/// `invalid_type` error should be constructed:
|
/// `invalid_type` error should be constructed:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||||
/// #
|
/// #
|
||||||
/// # struct X;
|
/// # struct X;
|
||||||
@@ -2100,7 +2100,7 @@ pub trait VariantAccess<'de>: Sized {
|
|||||||
/// If the data contains a different type of variant, the following
|
/// If the data contains a different type of variant, the following
|
||||||
/// `invalid_type` error should be constructed:
|
/// `invalid_type` error should be constructed:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||||
/// #
|
/// #
|
||||||
/// # struct X;
|
/// # struct X;
|
||||||
@@ -2147,7 +2147,7 @@ pub trait VariantAccess<'de>: Sized {
|
|||||||
/// If the data contains a different type of variant, the following
|
/// If the data contains a different type of variant, the following
|
||||||
/// `invalid_type` error should be constructed:
|
/// `invalid_type` error should be constructed:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
/// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected};
|
||||||
/// #
|
/// #
|
||||||
/// # struct X;
|
/// # struct X;
|
||||||
@@ -2207,14 +2207,10 @@ pub trait VariantAccess<'de>: Sized {
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// #[macro_use]
|
|
||||||
/// extern crate serde_derive;
|
|
||||||
///
|
|
||||||
/// extern crate serde;
|
|
||||||
///
|
|
||||||
/// use std::str::FromStr;
|
/// use std::str::FromStr;
|
||||||
/// use serde::de::{value, Deserialize, IntoDeserializer};
|
/// use serde::Deserialize;
|
||||||
|
/// use serde::de::{value, IntoDeserializer};
|
||||||
///
|
///
|
||||||
/// #[derive(Deserialize)]
|
/// #[derive(Deserialize)]
|
||||||
/// enum Setting {
|
/// enum Setting {
|
||||||
@@ -2229,8 +2225,6 @@ pub trait VariantAccess<'de>: Sized {
|
|||||||
/// Self::deserialize(s.into_deserializer())
|
/// Self::deserialize(s.into_deserializer())
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
pub trait IntoDeserializer<'de, E: Error = value::Error> {
|
pub trait IntoDeserializer<'de, E: Error = value::Error> {
|
||||||
/// The type of the deserializer being converted into.
|
/// The type of the deserializer being converted into.
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
//! Building blocks for deserializing basic values using the `IntoDeserializer`
|
//! Building blocks for deserializing basic values using the `IntoDeserializer`
|
||||||
//! trait.
|
//! trait.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```edition2018
|
||||||
//! #[macro_use]
|
|
||||||
//! extern crate serde_derive;
|
|
||||||
//!
|
|
||||||
//! extern crate serde;
|
|
||||||
//!
|
|
||||||
//! use std::str::FromStr;
|
//! use std::str::FromStr;
|
||||||
//! use serde::de::{value, Deserialize, IntoDeserializer};
|
//! use serde::Deserialize;
|
||||||
|
//! use serde::de::{value, IntoDeserializer};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Deserialize)]
|
//! #[derive(Deserialize)]
|
||||||
//! enum Setting {
|
//! enum Setting {
|
||||||
@@ -23,8 +19,6 @@
|
|||||||
//! Self::deserialize(s.into_deserializer())
|
//! Self::deserialize(s.into_deserializer())
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//! #
|
|
||||||
//! # fn main() {}
|
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use lib::*;
|
use lib::*;
|
||||||
|
|||||||
+6
-10
@@ -9,14 +9,12 @@
|
|||||||
/// do not need to bother with this macro and may assume support for 128-bit
|
/// do not need to bother with this macro and may assume support for 128-bit
|
||||||
/// integers.
|
/// integers.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// #[macro_use]
|
|
||||||
/// extern crate serde;
|
|
||||||
///
|
|
||||||
/// use serde::Serializer;
|
|
||||||
/// # use serde::private::ser::Error;
|
/// # use serde::private::ser::Error;
|
||||||
/// #
|
/// #
|
||||||
/// # struct MySerializer;
|
/// # struct MySerializer;
|
||||||
|
/// #
|
||||||
|
/// use serde::{serde_if_integer128, Serializer};
|
||||||
///
|
///
|
||||||
/// impl Serializer for MySerializer {
|
/// impl Serializer for MySerializer {
|
||||||
/// type Ok = ();
|
/// type Ok = ();
|
||||||
@@ -41,20 +39,18 @@
|
|||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
/// #
|
||||||
/// # __serialize_unimplemented! {
|
/// # serde::__serialize_unimplemented! {
|
||||||
/// # bool i8 i16 i32 u8 u16 u32 u64 f32 f64 char str bytes none some
|
/// # bool i8 i16 i32 u8 u16 u32 u64 f32 f64 char str bytes none some
|
||||||
/// # unit unit_struct unit_variant newtype_struct newtype_variant seq
|
/// # unit unit_struct unit_variant newtype_struct newtype_variant seq
|
||||||
/// # tuple tuple_struct tuple_variant map struct struct_variant
|
/// # tuple tuple_struct tuple_variant map struct struct_variant
|
||||||
/// # }
|
/// # }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// When Serde is built with support for 128-bit integers, this macro expands
|
/// When Serde is built with support for 128-bit integers, this macro expands
|
||||||
/// transparently into just the input tokens.
|
/// transparently into just the input tokens.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// macro_rules! serde_if_integer128 {
|
/// macro_rules! serde_if_integer128 {
|
||||||
/// ($($tt:tt)*) => {
|
/// ($($tt:tt)*) => {
|
||||||
/// $($tt)*
|
/// $($tt)*
|
||||||
@@ -65,7 +61,7 @@
|
|||||||
/// When built without support for 128-bit integers, this macro expands to
|
/// When built without support for 128-bit integers, this macro expands to
|
||||||
/// nothing.
|
/// nothing.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// macro_rules! serde_if_integer128 {
|
/// macro_rules! serde_if_integer128 {
|
||||||
/// ($($tt:tt)*) => {};
|
/// ($($tt:tt)*) => {};
|
||||||
/// }
|
/// }
|
||||||
|
|||||||
+4
-4
@@ -75,7 +75,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Serde types in rustdoc of other crates get linked to here.
|
// Serde types in rustdoc of other crates get linked to here.
|
||||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.83")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.84")]
|
||||||
// Support using Serde without the standard library!
|
// Support using Serde without the standard library!
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
// Unstable functionality only if the user asks for it. For tracking and
|
// Unstable functionality only if the user asks for it. For tracking and
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
#![cfg_attr(feature = "alloc", feature(alloc))]
|
#![cfg_attr(feature = "alloc", feature(alloc))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Whitelisted clippy lints
|
// Ignored clippy lints
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
allow(
|
allow(
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
zero_prefixed_literal
|
zero_prefixed_literal
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
// Whitelisted clippy_pedantic lints
|
// Ignored clippy_pedantic lints
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(
|
#![cfg_attr(feature = "cargo-clippy", allow(
|
||||||
// integer and float ser/de requires these sorts of casts
|
// integer and float ser/de requires these sorts of casts
|
||||||
cast_possible_truncation,
|
cast_possible_truncation,
|
||||||
@@ -112,11 +112,11 @@
|
|||||||
invalid_upcast_comparisons,
|
invalid_upcast_comparisons,
|
||||||
// things are often more readable this way
|
// things are often more readable this way
|
||||||
decimal_literal_representation,
|
decimal_literal_representation,
|
||||||
|
module_name_repetitions,
|
||||||
option_unwrap_used,
|
option_unwrap_used,
|
||||||
result_unwrap_used,
|
result_unwrap_used,
|
||||||
shadow_reuse,
|
shadow_reuse,
|
||||||
single_match_else,
|
single_match_else,
|
||||||
stutter,
|
|
||||||
use_self,
|
use_self,
|
||||||
// not practical
|
// not practical
|
||||||
indexing_slicing,
|
indexing_slicing,
|
||||||
|
|||||||
+6
-18
@@ -11,10 +11,8 @@
|
|||||||
/// input. This requires repetitive implementations of all the [`Deserializer`]
|
/// input. This requires repetitive implementations of all the [`Deserializer`]
|
||||||
/// trait methods.
|
/// trait methods.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::forward_to_deserialize_any;
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::de::{value, Deserializer, Visitor};
|
/// # use serde::de::{value, Deserializer, Visitor};
|
||||||
/// #
|
/// #
|
||||||
/// # struct MyDeserializer;
|
/// # struct MyDeserializer;
|
||||||
@@ -43,18 +41,14 @@
|
|||||||
/// # tuple_struct map struct enum identifier ignored_any
|
/// # tuple_struct map struct enum identifier ignored_any
|
||||||
/// # }
|
/// # }
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The `forward_to_deserialize_any!` macro implements these simple forwarding
|
/// The `forward_to_deserialize_any!` macro implements these simple forwarding
|
||||||
/// methods so that they forward directly to [`Deserializer::deserialize_any`].
|
/// methods so that they forward directly to [`Deserializer::deserialize_any`].
|
||||||
/// You can choose which methods to forward.
|
/// You can choose which methods to forward.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::forward_to_deserialize_any;
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::de::{value, Deserializer, Visitor};
|
/// # use serde::de::{value, Deserializer, Visitor};
|
||||||
/// #
|
/// #
|
||||||
/// # struct MyDeserializer;
|
/// # struct MyDeserializer;
|
||||||
@@ -77,8 +71,6 @@
|
|||||||
/// tuple_struct map struct enum identifier ignored_any
|
/// tuple_struct map struct enum identifier ignored_any
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// The macro assumes the convention that your `Deserializer` lifetime parameter
|
/// The macro assumes the convention that your `Deserializer` lifetime parameter
|
||||||
@@ -86,12 +78,10 @@
|
|||||||
/// called `V`. A different type parameter and a different lifetime can be
|
/// called `V`. A different type parameter and a different lifetime can be
|
||||||
/// specified explicitly if necessary.
|
/// specified explicitly if necessary.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use std::marker::PhantomData;
|
/// # use std::marker::PhantomData;
|
||||||
/// #
|
/// #
|
||||||
|
/// # use serde::forward_to_deserialize_any;
|
||||||
/// # use serde::de::{value, Deserializer, Visitor};
|
/// # use serde::de::{value, Deserializer, Visitor};
|
||||||
/// #
|
/// #
|
||||||
/// # struct MyDeserializer<V>(PhantomData<V>);
|
/// # struct MyDeserializer<V>(PhantomData<V>);
|
||||||
@@ -113,8 +103,6 @@
|
|||||||
/// tuple_struct map struct enum identifier ignored_any
|
/// tuple_struct map struct enum identifier ignored_any
|
||||||
/// }
|
/// }
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Deserializer`]: trait.Deserializer.html
|
/// [`Deserializer`]: trait.Deserializer.html
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ use ser::{
|
|||||||
/// [`SerializeTuple`], [`SerializeTupleStruct`], [`SerializeTupleVariant`],
|
/// [`SerializeTuple`], [`SerializeTupleStruct`], [`SerializeTupleVariant`],
|
||||||
/// [`SerializeMap`], [`SerializeStruct`], and [`SerializeStructVariant`].
|
/// [`SerializeMap`], [`SerializeStruct`], and [`SerializeStructVariant`].
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::ser::{Serializer, Impossible};
|
/// # use serde::ser::{Serializer, Impossible};
|
||||||
/// # use serde::private::ser::Error;
|
/// # use serde::private::ser::Error;
|
||||||
/// #
|
/// #
|
||||||
@@ -44,14 +41,12 @@ use ser::{
|
|||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// /* other Serializer methods */
|
/// /* other Serializer methods */
|
||||||
/// # __serialize_unimplemented! {
|
/// # serde::__serialize_unimplemented! {
|
||||||
/// # bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str bytes none some
|
/// # bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str bytes none some
|
||||||
/// # unit unit_struct unit_variant newtype_struct newtype_variant
|
/// # unit unit_struct unit_variant newtype_struct newtype_variant
|
||||||
/// # tuple tuple_struct tuple_variant map struct struct_variant
|
/// # tuple tuple_struct tuple_variant map struct struct_variant
|
||||||
/// # }
|
/// # }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Serializer`]: trait.Serializer.html
|
/// [`Serializer`]: trait.Serializer.html
|
||||||
|
|||||||
+65
-154
@@ -137,7 +137,7 @@ macro_rules! declare_error_trait {
|
|||||||
/// For example, a filesystem [`Path`] may refuse to serialize
|
/// For example, a filesystem [`Path`] may refuse to serialize
|
||||||
/// itself if it contains invalid UTF-8 data.
|
/// itself if it contains invalid UTF-8 data.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # struct Path;
|
/// # struct Path;
|
||||||
/// #
|
/// #
|
||||||
/// # impl Path {
|
/// # impl Path {
|
||||||
@@ -210,7 +210,7 @@ pub trait Serialize {
|
|||||||
/// See the [Implementing `Serialize`] section of the manual for more
|
/// See the [Implementing `Serialize`] section of the manual for more
|
||||||
/// information about how to implement this method.
|
/// information about how to implement this method.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||||
///
|
///
|
||||||
/// struct Person {
|
/// struct Person {
|
||||||
@@ -377,13 +377,10 @@ pub trait Serializer: Sized {
|
|||||||
|
|
||||||
/// Serialize a `bool` value.
|
/// Serialize a `bool` value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for bool {
|
/// impl Serialize for bool {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -393,8 +390,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_bool(*self)
|
/// serializer.serialize_bool(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>;
|
fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -404,13 +399,10 @@ pub trait Serializer: Sized {
|
|||||||
/// reasonable implementation would be to cast the value to `i64` and
|
/// reasonable implementation would be to cast the value to `i64` and
|
||||||
/// forward to `serialize_i64`.
|
/// forward to `serialize_i64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for i8 {
|
/// impl Serialize for i8 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -420,8 +412,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_i8(*self)
|
/// serializer.serialize_i8(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>;
|
fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -431,13 +421,10 @@ pub trait Serializer: Sized {
|
|||||||
/// reasonable implementation would be to cast the value to `i64` and
|
/// reasonable implementation would be to cast the value to `i64` and
|
||||||
/// forward to `serialize_i64`.
|
/// forward to `serialize_i64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for i16 {
|
/// impl Serialize for i16 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -447,8 +434,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_i16(*self)
|
/// serializer.serialize_i16(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>;
|
fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -458,13 +443,10 @@ pub trait Serializer: Sized {
|
|||||||
/// reasonable implementation would be to cast the value to `i64` and
|
/// reasonable implementation would be to cast the value to `i64` and
|
||||||
/// forward to `serialize_i64`.
|
/// forward to `serialize_i64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for i32 {
|
/// impl Serialize for i32 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -474,20 +456,15 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_i32(*self)
|
/// serializer.serialize_i32(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>;
|
fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
/// Serialize an `i64` value.
|
/// Serialize an `i64` value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for i64 {
|
/// impl Serialize for i64 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -497,21 +474,16 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_i64(*self)
|
/// serializer.serialize_i64(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>;
|
fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
serde_if_integer128! {
|
serde_if_integer128! {
|
||||||
/// Serialize an `i128` value.
|
/// Serialize an `i128` value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for i128 {
|
/// impl Serialize for i128 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -521,8 +493,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_i128(*self)
|
/// serializer.serialize_i128(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// This method is available only on Rust compiler versions >=1.26. The
|
/// This method is available only on Rust compiler versions >=1.26. The
|
||||||
@@ -539,13 +509,10 @@ pub trait Serializer: Sized {
|
|||||||
/// reasonable implementation would be to cast the value to `u64` and
|
/// reasonable implementation would be to cast the value to `u64` and
|
||||||
/// forward to `serialize_u64`.
|
/// forward to `serialize_u64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for u8 {
|
/// impl Serialize for u8 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -555,8 +522,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_u8(*self)
|
/// serializer.serialize_u8(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>;
|
fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -566,13 +531,10 @@ pub trait Serializer: Sized {
|
|||||||
/// reasonable implementation would be to cast the value to `u64` and
|
/// reasonable implementation would be to cast the value to `u64` and
|
||||||
/// forward to `serialize_u64`.
|
/// forward to `serialize_u64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for u16 {
|
/// impl Serialize for u16 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -582,8 +544,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_u16(*self)
|
/// serializer.serialize_u16(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>;
|
fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -593,13 +553,10 @@ pub trait Serializer: Sized {
|
|||||||
/// reasonable implementation would be to cast the value to `u64` and
|
/// reasonable implementation would be to cast the value to `u64` and
|
||||||
/// forward to `serialize_u64`.
|
/// forward to `serialize_u64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for u32 {
|
/// impl Serialize for u32 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -609,20 +566,15 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_u32(*self)
|
/// serializer.serialize_u32(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>;
|
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
/// Serialize a `u64` value.
|
/// Serialize a `u64` value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for u64 {
|
/// impl Serialize for u64 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -632,21 +584,16 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_u64(*self)
|
/// serializer.serialize_u64(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>;
|
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
serde_if_integer128! {
|
serde_if_integer128! {
|
||||||
/// Serialize a `u128` value.
|
/// Serialize a `u128` value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for u128 {
|
/// impl Serialize for u128 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -656,8 +603,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_u128(*self)
|
/// serializer.serialize_u128(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// This method is available only on Rust compiler versions >=1.26. The
|
/// This method is available only on Rust compiler versions >=1.26. The
|
||||||
@@ -674,13 +619,10 @@ pub trait Serializer: Sized {
|
|||||||
/// reasonable implementation would be to cast the value to `f64` and
|
/// reasonable implementation would be to cast the value to `f64` and
|
||||||
/// forward to `serialize_f64`.
|
/// forward to `serialize_f64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for f32 {
|
/// impl Serialize for f32 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -690,20 +632,15 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_f32(*self)
|
/// serializer.serialize_f32(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>;
|
fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
/// Serialize an `f64` value.
|
/// Serialize an `f64` value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for f64 {
|
/// impl Serialize for f64 {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -713,8 +650,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_f64(*self)
|
/// serializer.serialize_f64(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>;
|
fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -723,13 +658,10 @@ pub trait Serializer: Sized {
|
|||||||
/// If the format does not support characters, it is reasonable to serialize
|
/// If the format does not support characters, it is reasonable to serialize
|
||||||
/// it as a single element `str` or a `u32`.
|
/// it as a single element `str` or a `u32`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for char {
|
/// impl Serialize for char {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -739,20 +671,15 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_char(*self)
|
/// serializer.serialize_char(*self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>;
|
fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
/// Serialize a `&str`.
|
/// Serialize a `&str`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for str {
|
/// impl Serialize for str {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -762,8 +689,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_str(self)
|
/// serializer.serialize_str(self)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>;
|
fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -775,10 +700,7 @@ pub trait Serializer: Sized {
|
|||||||
/// `serialize_seq`. If forwarded, the implementation looks usually just
|
/// `serialize_seq`. If forwarded, the implementation looks usually just
|
||||||
/// like this:
|
/// like this:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::ser::{Serializer, SerializeSeq};
|
/// # use serde::ser::{Serializer, SerializeSeq};
|
||||||
/// # use serde::private::ser::Error;
|
/// # use serde::private::ser::Error;
|
||||||
/// #
|
/// #
|
||||||
@@ -796,22 +718,18 @@ pub trait Serializer: Sized {
|
|||||||
/// seq.end()
|
/// seq.end()
|
||||||
/// }
|
/// }
|
||||||
/// #
|
/// #
|
||||||
/// # __serialize_unimplemented! {
|
/// # serde::__serialize_unimplemented! {
|
||||||
/// # bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str none some
|
/// # bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str none some
|
||||||
/// # unit unit_struct unit_variant newtype_struct newtype_variant
|
/// # unit unit_struct unit_variant newtype_struct newtype_variant
|
||||||
/// # seq tuple tuple_struct tuple_variant map struct struct_variant
|
/// # seq tuple tuple_struct tuple_variant map struct struct_variant
|
||||||
/// # }
|
/// # }
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>;
|
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
/// Serialize a [`None`] value.
|
/// Serialize a [`None`] value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::{Serialize, Serializer};
|
/// # use serde::{Serialize, Serializer};
|
||||||
/// #
|
/// #
|
||||||
/// # enum Option<T> {
|
/// # enum Option<T> {
|
||||||
@@ -819,7 +737,7 @@ pub trait Serializer: Sized {
|
|||||||
/// # None,
|
/// # None,
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
/// #
|
||||||
/// # use Option::{Some, None};
|
/// # use self::Option::{Some, None};
|
||||||
/// #
|
/// #
|
||||||
/// impl<T> Serialize for Option<T>
|
/// impl<T> Serialize for Option<T>
|
||||||
/// where
|
/// where
|
||||||
@@ -844,9 +762,7 @@ pub trait Serializer: Sized {
|
|||||||
|
|
||||||
/// Serialize a [`Some(T)`] value.
|
/// Serialize a [`Some(T)`] value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::{Serialize, Serializer};
|
/// # use serde::{Serialize, Serializer};
|
||||||
/// #
|
/// #
|
||||||
/// # enum Option<T> {
|
/// # enum Option<T> {
|
||||||
@@ -854,7 +770,7 @@ pub trait Serializer: Sized {
|
|||||||
/// # None,
|
/// # None,
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
/// #
|
||||||
/// # use Option::{Some, None};
|
/// # use self::Option::{Some, None};
|
||||||
/// #
|
/// #
|
||||||
/// impl<T> Serialize for Option<T>
|
/// impl<T> Serialize for Option<T>
|
||||||
/// where
|
/// where
|
||||||
@@ -881,13 +797,10 @@ pub trait Serializer: Sized {
|
|||||||
|
|
||||||
/// Serialize a `()` value.
|
/// Serialize a `()` value.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// #
|
|
||||||
/// # use serde::Serializer;
|
/// # use serde::Serializer;
|
||||||
/// #
|
/// #
|
||||||
/// # __private_serialize!();
|
/// # serde::__private_serialize!();
|
||||||
/// #
|
/// #
|
||||||
/// impl Serialize for () {
|
/// impl Serialize for () {
|
||||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@@ -897,8 +810,6 @@ pub trait Serializer: Sized {
|
|||||||
/// serializer.serialize_unit()
|
/// serializer.serialize_unit()
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// #
|
|
||||||
/// # fn main() {}
|
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_unit(self) -> Result<Self::Ok, Self::Error>;
|
fn serialize_unit(self) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
@@ -906,7 +817,7 @@ pub trait Serializer: Sized {
|
|||||||
///
|
///
|
||||||
/// A reasonable implementation would be to forward to `serialize_unit`.
|
/// A reasonable implementation would be to forward to `serialize_unit`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::{Serialize, Serializer};
|
/// use serde::{Serialize, Serializer};
|
||||||
///
|
///
|
||||||
/// struct Nothing;
|
/// struct Nothing;
|
||||||
@@ -928,7 +839,7 @@ pub trait Serializer: Sized {
|
|||||||
/// this variant within the enum, and the `variant` is the name of the
|
/// this variant within the enum, and the `variant` is the name of the
|
||||||
/// variant.
|
/// variant.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::{Serialize, Serializer};
|
/// use serde::{Serialize, Serializer};
|
||||||
///
|
///
|
||||||
/// enum E {
|
/// enum E {
|
||||||
@@ -961,7 +872,7 @@ pub trait Serializer: Sized {
|
|||||||
/// wrappers around the data they contain. A reasonable implementation would
|
/// wrappers around the data they contain. A reasonable implementation would
|
||||||
/// be to forward to `value.serialize(self)`.
|
/// be to forward to `value.serialize(self)`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::{Serialize, Serializer};
|
/// use serde::{Serialize, Serializer};
|
||||||
///
|
///
|
||||||
/// struct Millimeters(u8);
|
/// struct Millimeters(u8);
|
||||||
@@ -989,7 +900,7 @@ pub trait Serializer: Sized {
|
|||||||
/// this variant within the enum, and the `variant` is the name of the
|
/// this variant within the enum, and the `variant` is the name of the
|
||||||
/// variant. The `value` is the data contained within this newtype variant.
|
/// variant. The `value` is the data contained within this newtype variant.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::{Serialize, Serializer};
|
/// use serde::{Serialize, Serializer};
|
||||||
///
|
///
|
||||||
/// enum E {
|
/// enum E {
|
||||||
@@ -1027,7 +938,7 @@ pub trait Serializer: Sized {
|
|||||||
/// not be computable before the sequence is iterated. Some serializers only
|
/// not be computable before the sequence is iterated. Some serializers only
|
||||||
/// support sequences whose length is known up front.
|
/// support sequences whose length is known up front.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::marker::PhantomData;
|
/// # use std::marker::PhantomData;
|
||||||
/// #
|
/// #
|
||||||
/// # struct Vec<T>(PhantomData<T>);
|
/// # struct Vec<T>(PhantomData<T>);
|
||||||
@@ -1072,7 +983,7 @@ pub trait Serializer: Sized {
|
|||||||
/// This call must be followed by zero or more calls to `serialize_element`,
|
/// This call must be followed by zero or more calls to `serialize_element`,
|
||||||
/// then a call to `end`.
|
/// then a call to `end`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, Serializer, SerializeTuple};
|
/// use serde::ser::{Serialize, Serializer, SerializeTuple};
|
||||||
///
|
///
|
||||||
/// # mod fool {
|
/// # mod fool {
|
||||||
@@ -1102,7 +1013,7 @@ pub trait Serializer: Sized {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeTuple, Serializer};
|
/// use serde::ser::{Serialize, SerializeTuple, Serializer};
|
||||||
///
|
///
|
||||||
/// const VRAM_SIZE: usize = 386;
|
/// const VRAM_SIZE: usize = 386;
|
||||||
@@ -1130,7 +1041,7 @@ pub trait Serializer: Sized {
|
|||||||
/// The `name` is the name of the tuple struct and the `len` is the number
|
/// The `name` is the name of the tuple struct and the `len` is the number
|
||||||
/// of data fields that will be serialized.
|
/// of data fields that will be serialized.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
|
/// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
|
||||||
///
|
///
|
||||||
/// struct Rgb(u8, u8, u8);
|
/// struct Rgb(u8, u8, u8);
|
||||||
@@ -1162,7 +1073,7 @@ pub trait Serializer: Sized {
|
|||||||
/// this variant within the enum, the `variant` is the name of the variant,
|
/// 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.
|
/// and the `len` is the number of data fields that will be serialized.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
|
/// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
|
||||||
///
|
///
|
||||||
/// enum E {
|
/// enum E {
|
||||||
@@ -1208,7 +1119,7 @@ pub trait Serializer: Sized {
|
|||||||
/// be computable before the map is iterated. Some serializers only support
|
/// be computable before the map is iterated. Some serializers only support
|
||||||
/// maps whose length is known up front.
|
/// maps whose length is known up front.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::marker::PhantomData;
|
/// # use std::marker::PhantomData;
|
||||||
/// #
|
/// #
|
||||||
/// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
|
/// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
|
||||||
@@ -1256,7 +1167,7 @@ pub trait Serializer: Sized {
|
|||||||
/// The `name` is the name of the struct and the `len` is the number of
|
/// The `name` is the name of the struct and the `len` is the number of
|
||||||
/// data fields that will be serialized.
|
/// data fields that will be serialized.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||||
///
|
///
|
||||||
/// struct Rgb {
|
/// struct Rgb {
|
||||||
@@ -1292,7 +1203,7 @@ pub trait Serializer: Sized {
|
|||||||
/// this variant within the enum, the `variant` is the name of the variant,
|
/// 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.
|
/// and the `len` is the number of data fields that will be serialized.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
|
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
|
||||||
///
|
///
|
||||||
/// enum E {
|
/// enum E {
|
||||||
@@ -1334,7 +1245,7 @@ pub trait Serializer: Sized {
|
|||||||
/// using [`serialize_seq`]. Implementors should not need to override this
|
/// using [`serialize_seq`]. Implementors should not need to override this
|
||||||
/// method.
|
/// method.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::{Serialize, Serializer};
|
/// use serde::{Serialize, Serializer};
|
||||||
///
|
///
|
||||||
/// struct SecretlyOneHigher {
|
/// struct SecretlyOneHigher {
|
||||||
@@ -1371,7 +1282,7 @@ pub trait Serializer: Sized {
|
|||||||
/// using [`serialize_map`]. Implementors should not need to override this
|
/// using [`serialize_map`]. Implementors should not need to override this
|
||||||
/// method.
|
/// method.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::{Serialize, Serializer};
|
/// use serde::{Serialize, Serializer};
|
||||||
/// use std::collections::BTreeSet;
|
/// use std::collections::BTreeSet;
|
||||||
///
|
///
|
||||||
@@ -1411,7 +1322,7 @@ pub trait Serializer: Sized {
|
|||||||
/// delegates to [`serialize_str`]. Serializers are encouraged to provide a
|
/// delegates to [`serialize_str`]. Serializers are encouraged to provide a
|
||||||
/// more efficient implementation if possible.
|
/// more efficient implementation if possible.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # struct DateTime;
|
/// # struct DateTime;
|
||||||
/// #
|
/// #
|
||||||
/// # impl DateTime {
|
/// # impl DateTime {
|
||||||
@@ -1452,7 +1363,7 @@ pub trait Serializer: Sized {
|
|||||||
/// of this method. If no more sensible behavior is possible, the
|
/// of this method. If no more sensible behavior is possible, the
|
||||||
/// implementation is expected to return an error.
|
/// implementation is expected to return an error.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # struct DateTime;
|
/// # struct DateTime;
|
||||||
/// #
|
/// #
|
||||||
/// # impl DateTime {
|
/// # impl DateTime {
|
||||||
@@ -1487,7 +1398,7 @@ pub trait Serializer: Sized {
|
|||||||
/// human-readable one and binary formats like Bincode will prefer the
|
/// human-readable one and binary formats like Bincode will prefer the
|
||||||
/// compact one.
|
/// compact one.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```edition2018
|
||||||
/// # use std::fmt::{self, Display};
|
/// # use std::fmt::{self, Display};
|
||||||
/// #
|
/// #
|
||||||
/// # struct Timestamp;
|
/// # struct Timestamp;
|
||||||
@@ -1536,7 +1447,7 @@ pub trait Serializer: Sized {
|
|||||||
///
|
///
|
||||||
/// # Example use
|
/// # Example use
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::marker::PhantomData;
|
/// # use std::marker::PhantomData;
|
||||||
/// #
|
/// #
|
||||||
/// # struct Vec<T>(PhantomData<T>);
|
/// # struct Vec<T>(PhantomData<T>);
|
||||||
@@ -1600,7 +1511,7 @@ pub trait SerializeSeq {
|
|||||||
///
|
///
|
||||||
/// # Example use
|
/// # Example use
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, Serializer, SerializeTuple};
|
/// use serde::ser::{Serialize, Serializer, SerializeTuple};
|
||||||
///
|
///
|
||||||
/// # mod fool {
|
/// # mod fool {
|
||||||
@@ -1630,7 +1541,7 @@ pub trait SerializeSeq {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::marker::PhantomData;
|
/// # use std::marker::PhantomData;
|
||||||
/// #
|
/// #
|
||||||
/// # struct Array<T>(PhantomData<T>);
|
/// # struct Array<T>(PhantomData<T>);
|
||||||
@@ -1700,7 +1611,7 @@ pub trait SerializeTuple {
|
|||||||
///
|
///
|
||||||
/// # Example use
|
/// # Example use
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
|
/// use serde::ser::{Serialize, SerializeTupleStruct, Serializer};
|
||||||
///
|
///
|
||||||
/// struct Rgb(u8, u8, u8);
|
/// struct Rgb(u8, u8, u8);
|
||||||
@@ -1745,7 +1656,7 @@ pub trait SerializeTupleStruct {
|
|||||||
///
|
///
|
||||||
/// # Example use
|
/// # Example use
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
|
/// use serde::ser::{Serialize, SerializeTupleVariant, Serializer};
|
||||||
///
|
///
|
||||||
/// enum E {
|
/// enum E {
|
||||||
@@ -1803,7 +1714,7 @@ pub trait SerializeTupleVariant {
|
|||||||
///
|
///
|
||||||
/// # Example use
|
/// # Example use
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use std::marker::PhantomData;
|
/// # use std::marker::PhantomData;
|
||||||
/// #
|
/// #
|
||||||
/// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
|
/// # struct HashMap<K, V>(PhantomData<K>, PhantomData<V>);
|
||||||
@@ -1914,7 +1825,7 @@ pub trait SerializeMap {
|
|||||||
///
|
///
|
||||||
/// # Example use
|
/// # Example use
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
|
||||||
///
|
///
|
||||||
/// struct Rgb {
|
/// struct Rgb {
|
||||||
@@ -1974,7 +1885,7 @@ pub trait SerializeStruct {
|
|||||||
///
|
///
|
||||||
/// # Example use
|
/// # Example use
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
|
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
|
||||||
///
|
///
|
||||||
/// enum E {
|
/// enum E {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.83" # remember to update html_root_url
|
version = "1.0.84" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
//! This crate provides Serde's two derive macros.
|
//! This crate provides Serde's two derive macros.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```edition2018
|
||||||
//! # #[macro_use]
|
//! # use serde_derive::{Serialize, Deserialize};
|
||||||
//! # extern crate serde_derive;
|
|
||||||
//! #
|
//! #
|
||||||
//! #[derive(Serialize, Deserialize)]
|
//! #[derive(Serialize, Deserialize)]
|
||||||
//! # struct S;
|
//! # struct S;
|
||||||
@@ -14,10 +13,10 @@
|
|||||||
//!
|
//!
|
||||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.83")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.84")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Whitelisted clippy lints
|
// Ignored clippy lints
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
allow(
|
allow(
|
||||||
@@ -26,10 +25,11 @@
|
|||||||
needless_pass_by_value,
|
needless_pass_by_value,
|
||||||
redundant_field_names,
|
redundant_field_names,
|
||||||
too_many_arguments,
|
too_many_arguments,
|
||||||
|
trivially_copy_pass_by_ref,
|
||||||
used_underscore_binding,
|
used_underscore_binding,
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
// Whitelisted clippy_pedantic lints
|
// Ignored clippy_pedantic lints
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
allow(
|
allow(
|
||||||
@@ -40,9 +40,9 @@
|
|||||||
indexing_slicing,
|
indexing_slicing,
|
||||||
items_after_statements,
|
items_after_statements,
|
||||||
match_same_arms,
|
match_same_arms,
|
||||||
|
module_name_repetitions,
|
||||||
similar_names,
|
similar_names,
|
||||||
single_match_else,
|
single_match_else,
|
||||||
stutter,
|
|
||||||
unseparated_literal_suffix,
|
unseparated_literal_suffix,
|
||||||
use_self,
|
use_self,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -299,8 +299,8 @@ fn serialize_struct_as_struct(
|
|||||||
|
|
||||||
let type_name = cattrs.name().serialize_name();
|
let type_name = cattrs.name().serialize_name();
|
||||||
|
|
||||||
let additional_field_count: usize = match cattrs.tag() {
|
let additional_field_count: usize = match *cattrs.tag() {
|
||||||
&attr::TagType::Internal { ref tag } => {
|
attr::TagType::Internal { ref tag } => {
|
||||||
let func = StructTrait::SerializeStruct.serialize_field(Span::call_site());
|
let func = StructTrait::SerializeStruct.serialize_field(Span::call_site());
|
||||||
serialize_fields.insert(
|
serialize_fields.insert(
|
||||||
0,
|
0,
|
||||||
@@ -319,7 +319,7 @@ fn serialize_struct_as_struct(
|
|||||||
.filter(|&field| !field.attrs.skip_serializing())
|
.filter(|&field| !field.attrs.skip_serializing())
|
||||||
.peekable();
|
.peekable();
|
||||||
|
|
||||||
let let_mut = mut_if(serialized_fields.peek().is_some());
|
let let_mut = mut_if(serialized_fields.peek().is_some() || additional_field_count > 0);
|
||||||
|
|
||||||
let len = serialized_fields
|
let len = serialized_fields
|
||||||
.map(|field| match field.attrs.skip_serializing_if() {
|
.map(|field| match field.attrs.skip_serializing_if() {
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
allow(
|
allow(
|
||||||
cyclomatic_complexity,
|
cyclomatic_complexity,
|
||||||
doc_markdown,
|
redundant_field_names,
|
||||||
match_same_arms,
|
trivially_copy_pass_by_ref
|
||||||
redundant_field_names
|
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.83" # remember to update html_root_url
|
version = "1.0.84" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||||
@@ -15,7 +15,7 @@ include = ["Cargo.toml", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-AP
|
|||||||
serde = { version = "1.0.60", path = "../serde" }
|
serde = { version = "1.0.60", path = "../serde" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde = { version = "1.0", path = "../serde", features = ["rc"] }
|
serde = { version = "1.0", path = "../serde" }
|
||||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
|
|||||||
+28
-52
@@ -8,13 +8,8 @@ use std::fmt::Debug;
|
|||||||
|
|
||||||
/// Runs both `assert_ser_tokens` and `assert_de_tokens`.
|
/// Runs both `assert_ser_tokens` and `assert_de_tokens`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -45,13 +40,8 @@ where
|
|||||||
|
|
||||||
/// Asserts that `value` serializes to the given `tokens`.
|
/// Asserts that `value` serializes to the given `tokens`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_ser_tokens, Token};
|
/// # use serde_test::{assert_ser_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -90,16 +80,11 @@ where
|
|||||||
/// Asserts that `value` serializes to the given `tokens`, and then yields
|
/// Asserts that `value` serializes to the given `tokens`, and then yields
|
||||||
/// `error`.
|
/// `error`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # fn main() {
|
|
||||||
/// use std::sync::{Arc, Mutex};
|
/// use std::sync::{Arc, Mutex};
|
||||||
/// use std::thread;
|
/// use std::thread;
|
||||||
///
|
///
|
||||||
|
/// use serde::Serialize;
|
||||||
/// use serde_test::{assert_ser_tokens_error, Token};
|
/// use serde_test::{assert_ser_tokens_error, Token};
|
||||||
///
|
///
|
||||||
/// #[derive(Serialize)]
|
/// #[derive(Serialize)]
|
||||||
@@ -107,26 +92,27 @@ where
|
|||||||
/// lock: Arc<Mutex<u32>>,
|
/// lock: Arc<Mutex<u32>>,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// let example = Example { lock: Arc::new(Mutex::new(0)) };
|
/// fn main() {
|
||||||
/// let lock = example.lock.clone();
|
/// let example = Example { lock: Arc::new(Mutex::new(0)) };
|
||||||
|
/// let lock = example.lock.clone();
|
||||||
///
|
///
|
||||||
/// let _ = thread::spawn(move || {
|
/// let _ = thread::spawn(move || {
|
||||||
/// // This thread will acquire the mutex first, unwrapping the result
|
/// // This thread will acquire the mutex first, unwrapping the result
|
||||||
/// // of `lock` because the lock has not been poisoned.
|
/// // of `lock` because the lock has not been poisoned.
|
||||||
/// let _guard = lock.lock().unwrap();
|
/// let _guard = lock.lock().unwrap();
|
||||||
///
|
///
|
||||||
/// // This panic while holding the lock (`_guard` is in scope) will
|
/// // This panic while holding the lock (`_guard` is in scope) will
|
||||||
/// // poison the mutex.
|
/// // poison the mutex.
|
||||||
/// panic!()
|
/// panic!()
|
||||||
/// }).join();
|
/// }).join();
|
||||||
///
|
///
|
||||||
/// let expected = &[
|
/// let expected = &[
|
||||||
/// Token::Struct { name: "Example", len: 1 },
|
/// Token::Struct { name: "Example", len: 1 },
|
||||||
/// Token::Str("lock"),
|
/// Token::Str("lock"),
|
||||||
/// ];
|
/// ];
|
||||||
/// let error = "lock poison error while serializing";
|
/// let error = "lock poison error while serializing";
|
||||||
/// assert_ser_tokens_error(&example, expected, error);
|
/// assert_ser_tokens_error(&example, expected, error);
|
||||||
/// # }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn assert_ser_tokens_error<T>(value: &T, tokens: &[Token], error: &str)
|
pub fn assert_ser_tokens_error<T>(value: &T, tokens: &[Token], error: &str)
|
||||||
where
|
where
|
||||||
@@ -145,13 +131,8 @@ where
|
|||||||
|
|
||||||
/// Asserts that the given `tokens` deserialize into `value`.
|
/// Asserts that the given `tokens` deserialize into `value`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_de_tokens, Token};
|
/// # use serde_test::{assert_de_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -205,13 +186,8 @@ where
|
|||||||
|
|
||||||
/// Asserts that the given `tokens` yield `error` when deserializing.
|
/// Asserts that the given `tokens` yield `error` when deserializing.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_de_tokens_error, Token};
|
/// # use serde_test::{assert_de_tokens_error, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ pub struct Compact<T: ?Sized>(T);
|
|||||||
/// Trait to determine whether a value is represented in human-readable or
|
/// Trait to determine whether a value is represented in human-readable or
|
||||||
/// compact form.
|
/// compact form.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```edition2018
|
||||||
/// extern crate serde;
|
|
||||||
/// extern crate serde_test;
|
|
||||||
///
|
|
||||||
/// use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
/// use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
/// use serde_test::{assert_tokens, Configure, Token};
|
/// use serde_test::{assert_tokens, Configure, Token};
|
||||||
///
|
///
|
||||||
|
|||||||
+7
-16
@@ -24,19 +24,10 @@
|
|||||||
//!
|
//!
|
||||||
//! [`linked-hash-map`]: https://github.com/contain-rs/linked-hash-map
|
//! [`linked-hash-map`]: https://github.com/contain-rs/linked-hash-map
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```edition2018
|
||||||
//! # extern crate serde;
|
//! # const IGNORE: &str = stringify! {
|
||||||
//! #
|
|
||||||
//! # macro_rules! ignore {
|
|
||||||
//! # ($($tt:tt)+) => {}
|
|
||||||
//! # }
|
|
||||||
//! #
|
|
||||||
//! # ignore! {
|
|
||||||
//! extern crate linked_hash_map;
|
|
||||||
//! use linked_hash_map::LinkedHashMap;
|
//! use linked_hash_map::LinkedHashMap;
|
||||||
//! # }
|
//! # };
|
||||||
//!
|
|
||||||
//! extern crate serde_test;
|
|
||||||
//! use serde_test::{Token, assert_tokens};
|
//! use serde_test::{Token, assert_tokens};
|
||||||
//!
|
//!
|
||||||
//! # use std::fmt;
|
//! # use std::fmt;
|
||||||
@@ -153,19 +144,19 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.83")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.84")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Whitelisted clippy lints
|
// Ignored clippy lints
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
|
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
|
||||||
// Whitelisted clippy_pedantic lints
|
// Ignored clippy_pedantic lints
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
allow(
|
allow(
|
||||||
empty_line_after_outer_attr,
|
empty_line_after_outer_attr,
|
||||||
missing_docs_in_private_items,
|
missing_docs_in_private_items,
|
||||||
|
module_name_repetitions,
|
||||||
redundant_field_names,
|
redundant_field_names,
|
||||||
stutter,
|
|
||||||
use_debug,
|
use_debug,
|
||||||
use_self
|
use_self
|
||||||
)
|
)
|
||||||
|
|||||||
+39
-84
@@ -4,7 +4,7 @@ use std::fmt::{self, Debug, Display};
|
|||||||
pub enum Token {
|
pub enum Token {
|
||||||
/// A serialized `bool`.
|
/// A serialized `bool`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&true, &[Token::Bool(true)]);
|
/// assert_tokens(&true, &[Token::Bool(true)]);
|
||||||
@@ -13,7 +13,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `i8`.
|
/// A serialized `i8`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0i8, &[Token::I8(0)]);
|
/// assert_tokens(&0i8, &[Token::I8(0)]);
|
||||||
@@ -22,7 +22,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `i16`.
|
/// A serialized `i16`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0i16, &[Token::I16(0)]);
|
/// assert_tokens(&0i16, &[Token::I16(0)]);
|
||||||
@@ -31,7 +31,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `i32`.
|
/// A serialized `i32`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0i32, &[Token::I32(0)]);
|
/// assert_tokens(&0i32, &[Token::I32(0)]);
|
||||||
@@ -40,7 +40,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `i64`.
|
/// A serialized `i64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0i64, &[Token::I64(0)]);
|
/// assert_tokens(&0i64, &[Token::I64(0)]);
|
||||||
@@ -49,7 +49,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `u8`.
|
/// A serialized `u8`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0u8, &[Token::U8(0)]);
|
/// assert_tokens(&0u8, &[Token::U8(0)]);
|
||||||
@@ -58,7 +58,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `u16`.
|
/// A serialized `u16`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0u16, &[Token::U16(0)]);
|
/// assert_tokens(&0u16, &[Token::U16(0)]);
|
||||||
@@ -67,7 +67,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `u32`.
|
/// A serialized `u32`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0u32, &[Token::U32(0)]);
|
/// assert_tokens(&0u32, &[Token::U32(0)]);
|
||||||
@@ -76,7 +76,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `u64`.
|
/// A serialized `u64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0u64, &[Token::U64(0)]);
|
/// assert_tokens(&0u64, &[Token::U64(0)]);
|
||||||
@@ -85,7 +85,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `f32`.
|
/// A serialized `f32`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0f32, &[Token::F32(0.0)]);
|
/// assert_tokens(&0f32, &[Token::F32(0.0)]);
|
||||||
@@ -94,7 +94,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `f64`.
|
/// A serialized `f64`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&0f64, &[Token::F64(0.0)]);
|
/// assert_tokens(&0f64, &[Token::F64(0.0)]);
|
||||||
@@ -103,7 +103,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `char`.
|
/// A serialized `char`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&'\n', &[Token::Char('\n')]);
|
/// assert_tokens(&'\n', &[Token::Char('\n')]);
|
||||||
@@ -112,7 +112,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `str`.
|
/// A serialized `str`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// let s = String::from("transient");
|
/// let s = String::from("transient");
|
||||||
@@ -122,7 +122,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A borrowed `str`.
|
/// A borrowed `str`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// let s: &str = "borrowed";
|
/// let s: &str = "borrowed";
|
||||||
@@ -132,7 +132,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `String`.
|
/// A serialized `String`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// let s = String::from("owned");
|
/// let s = String::from("owned");
|
||||||
@@ -151,7 +151,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `Option<T>` containing none.
|
/// A serialized `Option<T>` containing none.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// let opt = None::<char>;
|
/// let opt = None::<char>;
|
||||||
@@ -163,7 +163,7 @@ pub enum Token {
|
|||||||
///
|
///
|
||||||
/// The tokens of the value follow after this header.
|
/// The tokens of the value follow after this header.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// let opt = Some('c');
|
/// let opt = Some('c');
|
||||||
@@ -176,7 +176,7 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized `()`.
|
/// A serialized `()`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// assert_tokens(&(), &[Token::Unit]);
|
/// assert_tokens(&(), &[Token::Unit]);
|
||||||
@@ -185,13 +185,8 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A serialized unit struct of the given name.
|
/// A serialized unit struct of the given name.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -205,13 +200,8 @@ pub enum Token {
|
|||||||
|
|
||||||
/// A unit variant of an enum.
|
/// A unit variant of an enum.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -233,13 +223,8 @@ pub enum Token {
|
|||||||
///
|
///
|
||||||
/// After this header is the value contained in the newtype struct.
|
/// After this header is the value contained in the newtype struct.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -259,13 +244,8 @@ pub enum Token {
|
|||||||
///
|
///
|
||||||
/// After this header is the value contained in the newtype variant.
|
/// After this header is the value contained in the newtype variant.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -291,7 +271,7 @@ pub enum Token {
|
|||||||
/// After this header are the elements of the sequence, followed by
|
/// After this header are the elements of the sequence, followed by
|
||||||
/// `SeqEnd`.
|
/// `SeqEnd`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// let vec = vec!['a', 'b', 'c'];
|
/// let vec = vec!['a', 'b', 'c'];
|
||||||
@@ -312,7 +292,7 @@ pub enum Token {
|
|||||||
///
|
///
|
||||||
/// After this header are the elements of the tuple, followed by `TupleEnd`.
|
/// After this header are the elements of the tuple, followed by `TupleEnd`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// let tuple = ('a', 100);
|
/// let tuple = ('a', 100);
|
||||||
@@ -333,13 +313,8 @@ pub enum Token {
|
|||||||
/// After this header are the fields of the tuple struct, followed by
|
/// After this header are the fields of the tuple struct, followed by
|
||||||
/// `TupleStructEnd`.
|
/// `TupleStructEnd`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -365,13 +340,8 @@ pub enum Token {
|
|||||||
/// After this header are the fields of the tuple variant, followed by
|
/// After this header are the fields of the tuple variant, followed by
|
||||||
/// `TupleVariantEnd`.
|
/// `TupleVariantEnd`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -402,7 +372,7 @@ pub enum Token {
|
|||||||
///
|
///
|
||||||
/// After this header are the entries of the map, followed by `MapEnd`.
|
/// After this header are the entries of the map, followed by `MapEnd`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// use std::collections::BTreeMap;
|
/// use std::collections::BTreeMap;
|
||||||
@@ -429,13 +399,8 @@ pub enum Token {
|
|||||||
///
|
///
|
||||||
/// After this header are the fields of the struct, followed by `StructEnd`.
|
/// After this header are the fields of the struct, followed by `StructEnd`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -466,13 +431,8 @@ pub enum Token {
|
|||||||
/// After this header are the fields of the struct variant, followed by
|
/// After this header are the fields of the struct variant, followed by
|
||||||
/// `StructVariantEnd`.
|
/// `StructVariantEnd`.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
@@ -501,13 +461,8 @@ pub enum Token {
|
|||||||
|
|
||||||
/// The header to an enum of the given name.
|
/// The header to an enum of the given name.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```edition2018
|
||||||
/// # #[macro_use]
|
/// # use serde::{Serialize, Deserialize};
|
||||||
/// # extern crate serde_derive;
|
|
||||||
/// #
|
|
||||||
/// # extern crate serde;
|
|
||||||
/// # extern crate serde_test;
|
|
||||||
/// #
|
|
||||||
/// # use serde_test::{assert_tokens, Token};
|
/// # use serde_test::{assert_tokens, Token};
|
||||||
/// #
|
/// #
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
name = "serde_test_suite"
|
name = "serde_test_suite"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable = ["serde/unstable", "compiletest_rs"]
|
unstable = ["serde/unstable"]
|
||||||
|
compiletest = ["compiletest_rs"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
rustc-serialize = "0.3.16"
|
rustc-serialize = "0.3.16"
|
||||||
serde = { path = "../serde", features = ["rc"] }
|
serde = { path = "../serde", features = ["rc", "derive"] }
|
||||||
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
|
serde_derive = { path = "../serde_derive", features = ["deserialize_in_place"] }
|
||||||
serde_test = { path = "../serde_test" }
|
serde_test = { path = "../serde_test" }
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive_tests_no_std"
|
name = "serde_derive_tests_no_std"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = { version = "0.2", default-features = false }
|
libc = { version = "0.2", default-features = false }
|
||||||
serde = { path = "../../serde", default-features = false }
|
serde = { path = "../../serde", default-features = false, features = ["derive"] }
|
||||||
serde_derive = { path = "../../serde_derive" }
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#![feature(lang_items, start)]
|
#![feature(lang_items, start)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
extern crate libc;
|
|
||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||||
0
|
0
|
||||||
@@ -21,8 +19,7 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[macro_use]
|
use serde::{Serialize, Deserialize};
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct Unit;
|
struct Unit;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl<'de> Visitor<'de> for ByteBufVisitor {
|
|||||||
V: SeqAccess<'de>,
|
V: SeqAccess<'de>,
|
||||||
{
|
{
|
||||||
let mut values = Vec::new();
|
let mut values = Vec::new();
|
||||||
while let Some(value) = try!(visitor.next_element()) {
|
while let Some(value) = visitor.next_element()? {
|
||||||
values.push(value);
|
values.push(value);
|
||||||
}
|
}
|
||||||
Ok(values)
|
Ok(values)
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
#![cfg(feature = "unstable")]
|
#![cfg(feature = "compiletest")]
|
||||||
|
|
||||||
extern crate compiletest_rs as compiletest;
|
use compiletest_rs as compiletest;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ui() {
|
fn ui() {
|
||||||
let config = compiletest::Config {
|
let config = compiletest::Config {
|
||||||
mode: compiletest::common::Mode::Ui,
|
mode: compiletest::common::Mode::Ui,
|
||||||
src_base: std::path::PathBuf::from("tests/ui"),
|
src_base: std::path::PathBuf::from("tests/ui"),
|
||||||
target_rustcflags: Some("-L deps/target/debug/deps".to_owned()),
|
target_rustcflags: Some(String::from(
|
||||||
|
"\
|
||||||
|
--edition=2018 \
|
||||||
|
-L deps/target/debug/deps \
|
||||||
|
-Z unstable-options \
|
||||||
|
--extern serde_derive \
|
||||||
|
",
|
||||||
|
)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![allow(clippy::cast_lossless, clippy::trivially_copy_pass_by_ref)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))]
|
|
||||||
|
|
||||||
#[macro_use]
|
use serde::de::{self, MapAccess, Unexpected, Visitor};
|
||||||
extern crate serde_derive;
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
extern crate serde;
|
|
||||||
use self::serde::de::{self, MapAccess, Unexpected, Visitor};
|
|
||||||
use self::serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
||||||
|
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
extern crate serde_test;
|
use serde_test::{
|
||||||
use self::serde_test::{
|
|
||||||
assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_ser_tokens_error,
|
assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_ser_tokens_error,
|
||||||
assert_tokens, Token,
|
assert_tokens, Token,
|
||||||
};
|
};
|
||||||
@@ -68,7 +62,7 @@ impl DeserializeWith for i32 {
|
|||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
if try!(Deserialize::deserialize(de)) {
|
if Deserialize::deserialize(de)? {
|
||||||
Ok(123)
|
Ok(123)
|
||||||
} else {
|
} else {
|
||||||
Ok(2)
|
Ok(2)
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
extern crate serde;
|
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
|
|
||||||
extern crate serde_test;
|
|
||||||
use serde_test::{assert_de_tokens, assert_de_tokens_error, Token};
|
use serde_test::{assert_de_tokens, assert_de_tokens_error, Token};
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![allow(clippy::decimal_literal_representation)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(decimal_literal_representation))]
|
|
||||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::{CStr, CString, OsString};
|
use std::ffi::{CStr, CString, OsString};
|
||||||
@@ -15,14 +11,9 @@ use std::rc::{Rc, Weak as RcWeak};
|
|||||||
use std::sync::{Arc, Weak as ArcWeak};
|
use std::sync::{Arc, Weak as ArcWeak};
|
||||||
use std::time::{Duration, UNIX_EPOCH};
|
use std::time::{Duration, UNIX_EPOCH};
|
||||||
|
|
||||||
extern crate serde;
|
use fnv::FnvHasher;
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
|
use serde_test::{assert_de_tokens, assert_de_tokens_error, Configure, Token};
|
||||||
extern crate fnv;
|
|
||||||
use self::fnv::FnvHasher;
|
|
||||||
|
|
||||||
extern crate serde_test;
|
|
||||||
use self::serde_test::{assert_de_tokens, assert_de_tokens_error, Configure, Token};
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|||||||
@@ -4,13 +4,10 @@
|
|||||||
|
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![cfg_attr(feature = "unstable", feature(non_ascii_idents))]
|
#![cfg_attr(feature = "unstable", feature(non_ascii_idents))]
|
||||||
|
#![allow(clippy::trivially_copy_pass_by_ref)]
|
||||||
|
|
||||||
#[macro_use]
|
use serde::de::DeserializeOwned;
|
||||||
extern crate serde_derive;
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
extern crate serde;
|
|
||||||
use self::serde::de::{DeserializeOwned, Deserializer};
|
|
||||||
use self::serde::ser::{Serialize, Serializer};
|
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
@@ -384,6 +381,8 @@ fn test_gen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod vis {
|
mod vis {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub struct S;
|
pub struct S;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@@ -607,6 +606,8 @@ fn test_gen() {
|
|||||||
|
|
||||||
mod restricted {
|
mod restricted {
|
||||||
mod inner {
|
mod inner {
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct Restricted {
|
struct Restricted {
|
||||||
pub(super) a: usize,
|
pub(super) a: usize,
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
#[macro_use]
|
use serde::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
extern crate serde_test;
|
|
||||||
use serde_test::{assert_de_tokens, Token};
|
use serde_test::{assert_de_tokens, Token};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
#![deny(trivial_numeric_casts)]
|
#![deny(trivial_numeric_casts)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![allow(clippy::redundant_field_names)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
extern crate serde;
|
|
||||||
extern crate serde_test;
|
|
||||||
|
|
||||||
mod bytes;
|
mod bytes;
|
||||||
|
|
||||||
use self::serde_test::{
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_test::{
|
||||||
assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token,
|
assert_de_tokens, assert_de_tokens_error, assert_ser_tokens, assert_tokens, Token,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1413,6 +1407,23 @@ fn test_internally_tagged_struct() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_internally_tagged_braced_struct_with_zero_fields() {
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
struct S {}
|
||||||
|
|
||||||
|
assert_tokens(
|
||||||
|
&S {},
|
||||||
|
&[
|
||||||
|
Token::Struct { name: "S", len: 1 },
|
||||||
|
Token::Str("type"),
|
||||||
|
Token::Str("S"),
|
||||||
|
Token::StructEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_enum_in_untagged_enum() {
|
fn test_enum_in_untagged_enum() {
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![allow(clippy::redundant_field_names)]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
|
|
||||||
|
|
||||||
#[macro_use]
|
use serde::{Deserialize, Serialize};
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
mod remote {
|
mod remote {
|
||||||
pub struct Unit;
|
pub struct Unit;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
extern crate serde_test;
|
use serde_test::{assert_tokens, Configure, Token};
|
||||||
use self::serde_test::{assert_tokens, Configure, Token};
|
|
||||||
|
|
||||||
use std::net;
|
use std::net;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
#![cfg_attr(feature = "unstable", feature(never_type))]
|
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
@@ -17,11 +14,9 @@ use std::time::{Duration, UNIX_EPOCH};
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
extern crate serde_test;
|
use fnv::FnvHasher;
|
||||||
use self::serde_test::{assert_ser_tokens, assert_ser_tokens_error, Configure, Token};
|
use serde::Serialize;
|
||||||
|
use serde_test::{assert_ser_tokens, assert_ser_tokens_error, Configure, Token};
|
||||||
extern crate fnv;
|
|
||||||
use self::fnv::FnvHasher;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
extern crate serde;
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
extern crate serde_test;
|
|
||||||
|
|
||||||
// This test target is convoluted with the actual #[test] in a separate file to
|
// This test target is convoluted with the actual #[test] in a separate file to
|
||||||
// get it so that the stable compiler does not need to parse the code of the
|
// get it so that the stable compiler does not need to parse the code of the
|
||||||
// test. If the test were written with #[cfg(feature = "unstable")] #[test]
|
// test. If the test were written with #[cfg(feature = "unstable")] #[test]
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
extern crate serde;
|
|
||||||
use serde::de::{value, IntoDeserializer};
|
use serde::de::{value, IntoDeserializer};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Test<'a> {
|
struct Test<'a> {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: failed to parse borrowed lifetimes: "zzz"
|
error: failed to parse borrowed lifetimes: "zzz"
|
||||||
--> $DIR/bad_lifetimes.rs:6:22
|
--> $DIR/bad_lifetimes.rs:5:22
|
||||||
|
|
|
|
||||||
6 | #[serde(borrow = "zzz")]
|
5 | #[serde(borrow = "zzz")]
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Test<'a> {
|
struct Test<'a> {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate borrowed lifetime `'a`
|
error: duplicate borrowed lifetime `'a`
|
||||||
--> $DIR/duplicate_lifetime.rs:6:22
|
--> $DIR/duplicate_lifetime.rs:5:22
|
||||||
|
|
|
|
||||||
6 | #[serde(borrow = "'a + 'a")]
|
5 | #[serde(borrow = "'a + 'a")]
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Str<'a>(&'a str);
|
struct Str<'a>(&'a str);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate serde attribute `borrow`
|
error: duplicate serde attribute `borrow`
|
||||||
--> $DIR/duplicate_variant.rs:9:13
|
--> $DIR/duplicate_variant.rs:8:13
|
||||||
|
|
|
|
||||||
9 | #[serde(borrow)]
|
8 | #[serde(borrow)]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Test<'a> {
|
struct Test<'a> {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: at least one lifetime must be borrowed
|
error: at least one lifetime must be borrowed
|
||||||
--> $DIR/empty_lifetimes.rs:6:22
|
--> $DIR/empty_lifetimes.rs:5:22
|
||||||
|
|
|
|
||||||
6 | #[serde(borrow = "")]
|
5 | #[serde(borrow = "")]
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Test {
|
struct Test {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: field `s` has no lifetimes to borrow
|
error: field `s` has no lifetimes to borrow
|
||||||
--> $DIR/no_lifetimes.rs:6:5
|
--> $DIR/no_lifetimes.rs:5:5
|
||||||
|
|
|
|
||||||
6 | / #[serde(borrow)]
|
5 | / #[serde(borrow)]
|
||||||
7 | | s: String,
|
6 | | s: String,
|
||||||
| |_____________^
|
| |_____________^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Str<'a>(&'a str);
|
struct Str<'a>(&'a str);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
error: #[serde(borrow)] may only be used on newtype variants
|
error: #[serde(borrow)] may only be used on newtype variants
|
||||||
--> $DIR/struct_variant.rs:9:5
|
--> $DIR/struct_variant.rs:8:5
|
||||||
|
|
|
|
||||||
9 | / #[serde(borrow)]
|
8 | / #[serde(borrow)]
|
||||||
10 | | S { s: Str<'a> },
|
9 | | S { s: Str<'a> },
|
||||||
| |____________________^
|
| |____________________^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Test<'a> {
|
struct Test<'a> {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: field `s` does not have lifetime 'b
|
error: field `s` does not have lifetime 'b
|
||||||
--> $DIR/wrong_lifetime.rs:6:5
|
--> $DIR/wrong_lifetime.rs:5:5
|
||||||
|
|
|
|
||||||
6 | / #[serde(borrow = "'b")]
|
5 | / #[serde(borrow = "'b")]
|
||||||
7 | | s: &'a str,
|
6 | | s: &'a str,
|
||||||
| |______________^
|
| |______________^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(tag = "conflict", content = "conflict")]
|
#[serde(tag = "conflict", content = "conflict")]
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
error: enum tags `conflict` for type and content conflict with each other
|
error: enum tags `conflict` for type and content conflict with each other
|
||||||
--> $DIR/adjacent-tag.rs:5:1
|
--> $DIR/adjacent-tag.rs:4:1
|
||||||
|
|
|
|
||||||
5 | / #[serde(tag = "conflict", content = "conflict")]
|
4 | / #[serde(tag = "conflict", content = "conflict")]
|
||||||
6 | | enum E {
|
5 | | enum E {
|
||||||
7 | | A,
|
6 | | A,
|
||||||
8 | | B,
|
7 | | B,
|
||||||
9 | | }
|
8 | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Foo(#[serde(flatten)] HashMap<String, String>);
|
struct Foo(#[serde(flatten)] HashMap<String, String>);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(flatten)] cannot be used on newtype structs
|
error: #[serde(flatten)] cannot be used on newtype structs
|
||||||
--> $DIR/flatten-newtype-struct.rs:5:12
|
--> $DIR/flatten-newtype-struct.rs:6:12
|
||||||
|
|
|
|
||||||
5 | struct Foo(#[serde(flatten)] HashMap<String, String>);
|
6 | struct Foo(#[serde(flatten)] HashMap<String, String>);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: #[serde(flatten)] can not be combined with #[serde(skip_deserializing)]
|
error: #[serde(flatten)] can not be combined with #[serde(skip_deserializing)]
|
||||||
--> $DIR/flatten-skip-deserializing.rs:6:5
|
--> $DIR/flatten-skip-deserializing.rs:5:5
|
||||||
|
|
|
|
||||||
6 | / #[serde(flatten, skip_deserializing)]
|
5 | / #[serde(flatten, skip_deserializing)]
|
||||||
7 | | other: Other,
|
6 | | other: Other,
|
||||||
| |________________^
|
| |________________^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: #[serde(flatten)] can not be combined with #[serde(skip_serializing_if = "...")]
|
error: #[serde(flatten)] can not be combined with #[serde(skip_serializing_if = "...")]
|
||||||
--> $DIR/flatten-skip-serializing-if.rs:6:5
|
--> $DIR/flatten-skip-serializing-if.rs:5:5
|
||||||
|
|
|
|
||||||
6 | / #[serde(flatten, skip_serializing_if = "Option::is_none")]
|
5 | / #[serde(flatten, skip_serializing_if = "Option::is_none")]
|
||||||
7 | | other: Option<Other>,
|
6 | | other: Option<Other>,
|
||||||
| |________________________^
|
| |________________________^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: #[serde(flatten)] can not be combined with #[serde(skip_serializing)]
|
error: #[serde(flatten)] can not be combined with #[serde(skip_serializing)]
|
||||||
--> $DIR/flatten-skip-serializing.rs:6:5
|
--> $DIR/flatten-skip-serializing.rs:5:5
|
||||||
|
|
|
|
||||||
6 | / #[serde(flatten, skip_serializing)]
|
5 | / #[serde(flatten, skip_serializing)]
|
||||||
7 | | other: Other,
|
6 | | other: Other,
|
||||||
| |________________^
|
| |________________^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
|
struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(flatten)] cannot be used on tuple structs
|
error: #[serde(flatten)] cannot be used on tuple structs
|
||||||
--> $DIR/flatten-tuple-struct.rs:5:17
|
--> $DIR/flatten-tuple-struct.rs:6:17
|
||||||
|
|
|
|
||||||
5 | struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
|
6 | struct Foo(u32, #[serde(flatten)] HashMap<String, String>);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(tag = "conflict")]
|
#[serde(tag = "conflict")]
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
error: variant field name `conflict` conflicts with internal tag
|
error: variant field name `conflict` conflicts with internal tag
|
||||||
--> $DIR/internal-tag.rs:5:1
|
--> $DIR/internal-tag.rs:4:1
|
||||||
|
|
|
|
||||||
5 | / #[serde(tag = "conflict")]
|
4 | / #[serde(tag = "conflict")]
|
||||||
6 | | enum E {
|
5 | | enum E {
|
||||||
7 | | A {
|
6 | | A {
|
||||||
8 | | #[serde(rename = "conflict")]
|
7 | | #[serde(rename = "conflict")]
|
||||||
9 | | x: (),
|
8 | | x: (),
|
||||||
10 | | },
|
9 | | },
|
||||||
11 | | }
|
10 | | }
|
||||||
| |_^
|
| |_^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
enum E {
|
enum E {
|
||||||
S { f: u8 },
|
S { f: u8 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(default)] can only be used on structs with named fields
|
error: #[serde(default)] can only be used on structs with named fields
|
||||||
--> $DIR/enum.rs:6:1
|
--> $DIR/enum.rs:5:1
|
||||||
|
|
|
|
||||||
6 | enum E {
|
5 | enum E {
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(default = "default_e")]
|
#[serde(default = "default_e")]
|
||||||
enum E {
|
enum E {
|
||||||
S { f: u8 },
|
S { f: u8 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(default = "...")] can only be used on structs with named fields
|
error: #[serde(default = "...")] can only be used on structs with named fields
|
||||||
--> $DIR/enum_path.rs:6:1
|
--> $DIR/enum_path.rs:5:1
|
||||||
|
|
|
|
||||||
6 | enum E {
|
5 | enum E {
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(default)] can only be used on structs with named fields
|
error: #[serde(default)] can only be used on structs with named fields
|
||||||
--> $DIR/nameless_struct_fields.rs:6:9
|
--> $DIR/nameless_struct_fields.rs:5:9
|
||||||
|
|
|
|
||||||
6 | struct T(u8, u8);
|
5 | struct T(u8, u8);
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Deserialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(default = "default_t")]
|
#[serde(default = "default_t")]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(default = "...")] can only be used on structs with named fields
|
error: #[serde(default = "...")] can only be used on structs with named fields
|
||||||
--> $DIR/nameless_struct_fields_path.rs:6:9
|
--> $DIR/nameless_struct_fields_path.rs:5:9
|
||||||
|
|
|
|
||||||
6 | struct T(u8, u8);
|
5 | struct T(u8, u8);
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: unknown serde field attribute `serialize`
|
error: unknown serde field attribute `serialize`
|
||||||
--> $DIR/rename-and-ser.rs:6:27
|
--> $DIR/rename-and-ser.rs:5:27
|
||||||
|
|
|
|
||||||
6 | #[serde(rename = "x", serialize = "y")]
|
5 | #[serde(rename = "x", serialize = "y")]
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate serde attribute `rename`
|
error: duplicate serde attribute `rename`
|
||||||
--> $DIR/rename-rename-de.rs:7:13
|
--> $DIR/rename-rename-de.rs:6:13
|
||||||
|
|
|
|
||||||
7 | #[serde(rename(deserialize = "y"))]
|
6 | #[serde(rename(deserialize = "y"))]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate serde attribute `rename`
|
error: duplicate serde attribute `rename`
|
||||||
--> $DIR/rename-ser-rename-ser.rs:6:38
|
--> $DIR/rename-ser-rename-ser.rs:5:38
|
||||||
|
|
|
|
||||||
6 | #[serde(rename(serialize = "x"), rename(serialize = "y"))]
|
5 | #[serde(rename(serialize = "x"), rename(serialize = "y"))]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate serde attribute `rename`
|
error: duplicate serde attribute `rename`
|
||||||
--> $DIR/rename-ser-rename.rs:7:13
|
--> $DIR/rename-ser-rename.rs:6:13
|
||||||
|
|
|
|
||||||
7 | #[serde(rename = "y")]
|
6 | #[serde(rename = "y")]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate serde attribute `rename`
|
error: duplicate serde attribute `rename`
|
||||||
--> $DIR/rename-ser-ser.rs:6:37
|
--> $DIR/rename-ser-ser.rs:5:37
|
||||||
|
|
|
|
||||||
6 | #[serde(rename(serialize = "x", serialize = "y"))]
|
5 | #[serde(rename(serialize = "x", serialize = "y"))]
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate serde attribute `rename`
|
error: duplicate serde attribute `rename`
|
||||||
--> $DIR/two-rename-ser.rs:7:13
|
--> $DIR/two-rename-ser.rs:6:13
|
||||||
|
|
|
|
||||||
7 | #[serde(rename(serialize = "y"))]
|
6 | #[serde(rename(serialize = "y"))]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: duplicate serde attribute `serialize_with`
|
error: duplicate serde attribute `serialize_with`
|
||||||
--> $DIR/with-and-serialize-with.rs:6:25
|
--> $DIR/with-and-serialize-with.rs:5:25
|
||||||
|
|
|
|
||||||
6 | #[serde(with = "w", serialize_with = "s")]
|
5 | #[serde(with = "w", serialize_with = "s")]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(content = "c")]
|
#[serde(content = "c")]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(tag = "...", content = "...")] must be used together
|
error: #[serde(tag = "...", content = "...")] must be used together
|
||||||
--> $DIR/content-no-tag.rs:5:9
|
--> $DIR/content-no-tag.rs:4:9
|
||||||
|
|
|
|
||||||
5 | #[serde(content = "c")]
|
4 | #[serde(content = "c")]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(tag = "...")] cannot be used with tuple variants
|
error: #[serde(tag = "...")] cannot be used with tuple variants
|
||||||
--> $DIR/internal-tuple-variant.rs:7:5
|
--> $DIR/internal-tuple-variant.rs:6:5
|
||||||
|
|
|
|
||||||
7 | Tuple(u8, u8),
|
6 | Tuple(u8, u8),
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
||||||
--> $DIR/untagged-and-adjacent.rs:5:9
|
--> $DIR/untagged-and-adjacent.rs:4:9
|
||||||
|
|
|
|
||||||
5 | #[serde(untagged)]
|
4 | #[serde(untagged)]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
||||||
--> $DIR/untagged-and-adjacent.rs:6:9
|
--> $DIR/untagged-and-adjacent.rs:5:9
|
||||||
|
|
|
|
||||||
6 | #[serde(tag = "t", content = "c")]
|
5 | #[serde(tag = "t", content = "c")]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
error: untagged enum cannot have #[serde(tag = "...", content = "...")]
|
||||||
--> $DIR/untagged-and-adjacent.rs:6:20
|
--> $DIR/untagged-and-adjacent.rs:5:20
|
||||||
|
|
|
|
||||||
6 | #[serde(tag = "t", content = "c")]
|
5 | #[serde(tag = "t", content = "c")]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
error: untagged enum cannot have #[serde(content = "...")]
|
error: untagged enum cannot have #[serde(content = "...")]
|
||||||
--> $DIR/untagged-and-content.rs:5:9
|
--> $DIR/untagged-and-content.rs:4:9
|
||||||
|
|
|
|
||||||
5 | #[serde(untagged)]
|
4 | #[serde(untagged)]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: untagged enum cannot have #[serde(content = "...")]
|
error: untagged enum cannot have #[serde(content = "...")]
|
||||||
--> $DIR/untagged-and-content.rs:6:9
|
--> $DIR/untagged-and-content.rs:5:9
|
||||||
|
|
|
|
||||||
6 | #[serde(content = "c")]
|
5 | #[serde(content = "c")]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
error: enum cannot be both untagged and internally tagged
|
error: enum cannot be both untagged and internally tagged
|
||||||
--> $DIR/untagged-and-internal.rs:5:9
|
--> $DIR/untagged-and-internal.rs:4:9
|
||||||
|
|
|
|
||||||
5 | #[serde(untagged)]
|
4 | #[serde(untagged)]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: enum cannot be both untagged and internally tagged
|
error: enum cannot be both untagged and internally tagged
|
||||||
--> $DIR/untagged-and-internal.rs:6:9
|
--> $DIR/untagged-and-internal.rs:5:9
|
||||||
|
|
|
|
||||||
6 | #[serde(tag = "type")]
|
5 | #[serde(tag = "type")]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: #[serde(untagged)] can only be used on enums
|
error: #[serde(untagged)] can only be used on enums
|
||||||
--> $DIR/untagged-struct.rs:6:1
|
--> $DIR/untagged-struct.rs:5:1
|
||||||
|
|
|
|
||||||
6 | struct S;
|
5 | struct S;
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#[macro_use]
|
use serde_derive::Serialize;
|
||||||
extern crate serde_derive;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
error: expected serde rename attribute to be a string: `rename = "..."`
|
error: expected serde rename attribute to be a string: `rename = "..."`
|
||||||
--> $DIR/boolean.rs:6:22
|
--> $DIR/boolean.rs:5:22
|
||||||
|
|
|
|
||||||
6 | #[serde(rename = true)]
|
5 | #[serde(rename = true)]
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user