mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-29 00:17:55 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b539cb45d7 | |||
| a5490e20e1 | |||
| 45c45e87bf | |||
| 2e76f7013f | |||
| d35de19120 | |||
| e5b3507145 | |||
| 7ea7c2ceb9 | |||
| 2b5b15967e | |||
| 2ef60b62ac | |||
| e6f086d85e | |||
| bf76f50294 | |||
| ba07075590 | |||
| 26186bddd1 | |||
| 53b9871b17 | |||
| f8787c3ca8 | |||
| 3022064f84 | |||
| 9e140a2071 | |||
| 24e6acbfae | |||
| 29c5a50935 | |||
| c619b2a7c4 | |||
| 764ebd9b17 | |||
| 9c6f0c3a0e | |||
| a9f8ea0a1e | |||
| 04faac962a | |||
| 7e5701ad2b | |||
| 1cd10a7d09 | |||
| d5e6436b28 | |||
| 8ff11dc234 | |||
| 6b3777b617 |
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
name: Help or discussion
|
|
||||||
about: This is the right place
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
+1
-1
@@ -58,4 +58,4 @@ In all Serde-related forums, we follow the [Rust Code of Conduct]. For
|
|||||||
escalation or moderation issues please contact Erick (erick.tryzelaar@gmail.com)
|
escalation or moderation issues please contact Erick (erick.tryzelaar@gmail.com)
|
||||||
instead of the Rust moderation team.
|
instead of the Rust moderation team.
|
||||||
|
|
||||||
[Rust Code of Conduct]: https://www.rust-lang.org/conduct.html
|
[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
error_on_line_overflow = false
|
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.113" # remember to update html_root_url and serde_derive dependency
|
version = "1.0.116" # remember to update html_root_url and serde_derive dependency
|
||||||
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 OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
@@ -14,7 +14,7 @@ include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APAC
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.113", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "=1.0.116", 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" }
|
||||||
|
|||||||
@@ -1313,7 +1313,7 @@ macro_rules! variant_identifier {
|
|||||||
formatter.write_str($expecting_message)
|
formatter.write_str($expecting_message)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
|
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
{
|
{
|
||||||
@@ -1321,7 +1321,7 @@ macro_rules! variant_identifier {
|
|||||||
$(
|
$(
|
||||||
$index => Ok($name_kind :: $variant),
|
$index => Ok($name_kind :: $variant),
|
||||||
)*
|
)*
|
||||||
_ => Err(Error::invalid_value(Unexpected::Unsigned(value as u64), &self),),
|
_ => Err(Error::invalid_value(Unexpected::Unsigned(value), &self),),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2326,7 +2326,7 @@ where
|
|||||||
formatter.write_str("`Unbounded`, `Included` or `Excluded`")
|
formatter.write_str("`Unbounded`, `Included` or `Excluded`")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
|
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
{
|
{
|
||||||
@@ -2335,7 +2335,7 @@ where
|
|||||||
1 => Ok(Field::Included),
|
1 => Ok(Field::Included),
|
||||||
2 => Ok(Field::Excluded),
|
2 => Ok(Field::Excluded),
|
||||||
_ => Err(Error::invalid_value(
|
_ => Err(Error::invalid_value(
|
||||||
Unexpected::Unsigned(value as u64),
|
Unexpected::Unsigned(value),
|
||||||
&self,
|
&self,
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
@@ -2492,7 +2492,7 @@ where
|
|||||||
formatter.write_str("`Ok` or `Err`")
|
formatter.write_str("`Ok` or `Err`")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_u32<E>(self, value: u32) -> Result<Self::Value, E>
|
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
|
||||||
where
|
where
|
||||||
E: Error,
|
E: Error,
|
||||||
{
|
{
|
||||||
@@ -2500,7 +2500,7 @@ where
|
|||||||
0 => Ok(Field::Ok),
|
0 => Ok(Field::Ok),
|
||||||
1 => Ok(Field::Err),
|
1 => Ok(Field::Err),
|
||||||
_ => Err(Error::invalid_value(
|
_ => Err(Error::invalid_value(
|
||||||
Unexpected::Unsigned(value as u64),
|
Unexpected::Unsigned(value),
|
||||||
&self,
|
&self,
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -104,7 +104,7 @@
|
|||||||
//! [`Deserialize`]: ../trait.Deserialize.html
|
//! [`Deserialize`]: ../trait.Deserialize.html
|
||||||
//! [`Deserializer`]: ../trait.Deserializer.html
|
//! [`Deserializer`]: ../trait.Deserializer.html
|
||||||
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
||||||
//! [`bincode`]: https://github.com/TyOverby/bincode
|
//! [`bincode`]: https://github.com/servo/bincode
|
||||||
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||||
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||||
//! [`serde_json`]: https://github.com/serde-rs/json
|
//! [`serde_json`]: https://github.com/serde-rs/json
|
||||||
|
|||||||
+8
-7
@@ -37,8 +37,8 @@
|
|||||||
//! used for IPC within the Servo rendering engine.
|
//! used for IPC within the Servo rendering engine.
|
||||||
//! - [CBOR], a Concise Binary Object Representation designed for small message
|
//! - [CBOR], a Concise Binary Object Representation designed for small message
|
||||||
//! size without the need for version negotiation.
|
//! size without the need for version negotiation.
|
||||||
//! - [YAML], a popular human-friendly configuration language that ain't markup
|
//! - [YAML], a self-proclaimed human-friendly configuration language that ain't
|
||||||
//! language.
|
//! markup language.
|
||||||
//! - [MessagePack], an efficient binary format that resembles a compact JSON.
|
//! - [MessagePack], an efficient binary format that resembles a compact JSON.
|
||||||
//! - [TOML], a minimal configuration format used by [Cargo].
|
//! - [TOML], a minimal configuration format used by [Cargo].
|
||||||
//! - [Pickle], a format common in the Python world.
|
//! - [Pickle], a format common in the Python world.
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
//! definition.
|
//! definition.
|
||||||
//! - [JSON5], A superset of JSON including some productions from ES5.
|
//! - [JSON5], A superset of JSON including some productions from ES5.
|
||||||
//! - [Postcard], a no\_std and embedded-systems friendly compact binary format.
|
//! - [Postcard], a no\_std and embedded-systems friendly compact binary format.
|
||||||
//! - [URL], the x-www-form-urlencoded format.
|
//! - [URL] query strings, in the x-www-form-urlencoded format.
|
||||||
//! - [Envy], a way to deserialize environment variables into Rust structs.
|
//! - [Envy], a way to deserialize environment variables into Rust structs.
|
||||||
//! *(deserialization only)*
|
//! *(deserialization only)*
|
||||||
//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
|
//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
//! - [FlexBuffers], the schemaless cousin of Google's FlatBuffers zero-copy serialization format.
|
//! - [FlexBuffers], the schemaless cousin of Google's FlatBuffers zero-copy serialization format.
|
||||||
//!
|
//!
|
||||||
//! [JSON]: https://github.com/serde-rs/json
|
//! [JSON]: https://github.com/serde-rs/json
|
||||||
//! [Bincode]: https://github.com/TyOverby/bincode
|
//! [Bincode]: https://github.com/servo/bincode
|
||||||
//! [CBOR]: https://github.com/pyfisch/cbor
|
//! [CBOR]: https://github.com/pyfisch/cbor
|
||||||
//! [YAML]: https://github.com/dtolnay/serde-yaml
|
//! [YAML]: https://github.com/dtolnay/serde-yaml
|
||||||
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
|
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
//! [Avro]: https://github.com/flavray/avro-rs
|
//! [Avro]: https://github.com/flavray/avro-rs
|
||||||
//! [JSON5]: https://github.com/callum-oakley/json5-rs
|
//! [JSON5]: https://github.com/callum-oakley/json5-rs
|
||||||
//! [Postcard]: https://github.com/jamesmunns/postcard
|
//! [Postcard]: https://github.com/jamesmunns/postcard
|
||||||
//! [URL]: https://github.com/nox/serde_urlencoded
|
//! [URL]: https://docs.rs/serde_qs
|
||||||
//! [Envy]: https://github.com/softprops/envy
|
//! [Envy]: https://github.com/softprops/envy
|
||||||
//! [Envy Store]: https://github.com/softprops/envy-store
|
//! [Envy Store]: https://github.com/softprops/envy-store
|
||||||
//! [Cargo]: http://doc.crates.io/manifest.html
|
//! [Cargo]: http://doc.crates.io/manifest.html
|
||||||
@@ -82,14 +82,14 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// 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.113")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.116")]
|
||||||
// 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
|
||||||
// discussion of these features please refer to this issue:
|
// discussion of these features please refer to this issue:
|
||||||
//
|
//
|
||||||
// https://github.com/serde-rs/serde/issues/812
|
// https://github.com/serde-rs/serde/issues/812
|
||||||
#![cfg_attr(feature = "unstable", feature(specialization, never_type))]
|
#![cfg_attr(feature = "unstable", feature(never_type))]
|
||||||
#![allow(unknown_lints, bare_trait_objects, deprecated)]
|
#![allow(unknown_lints, bare_trait_objects, deprecated)]
|
||||||
#![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))]
|
||||||
@@ -111,6 +111,7 @@
|
|||||||
// things are often more readable this way
|
// things are often more readable this way
|
||||||
cast_lossless,
|
cast_lossless,
|
||||||
module_name_repetitions,
|
module_name_repetitions,
|
||||||
|
option_if_let_else,
|
||||||
single_match_else,
|
single_match_else,
|
||||||
type_complexity,
|
type_complexity,
|
||||||
use_self,
|
use_self,
|
||||||
|
|||||||
@@ -2763,6 +2763,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||||
|
where
|
||||||
|
V: Visitor<'de>,
|
||||||
|
{
|
||||||
|
visitor.visit_unit()
|
||||||
|
}
|
||||||
|
|
||||||
forward_to_deserialize_other! {
|
forward_to_deserialize_other! {
|
||||||
deserialize_bool()
|
deserialize_bool()
|
||||||
deserialize_i8()
|
deserialize_i8()
|
||||||
@@ -2780,7 +2787,6 @@ where
|
|||||||
deserialize_string()
|
deserialize_string()
|
||||||
deserialize_bytes()
|
deserialize_bytes()
|
||||||
deserialize_byte_buf()
|
deserialize_byte_buf()
|
||||||
deserialize_unit()
|
|
||||||
deserialize_unit_struct(&'static str)
|
deserialize_unit_struct(&'static str)
|
||||||
deserialize_seq()
|
deserialize_seq()
|
||||||
deserialize_tuple(usize)
|
deserialize_tuple(usize)
|
||||||
|
|||||||
@@ -1124,7 +1124,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
|
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
|
||||||
Err(Self::bad_type(Unsupported::Unit))
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
|
fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
|
||||||
|
|||||||
+3
-32
@@ -99,7 +99,7 @@
|
|||||||
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
|
||||||
//! [`Serialize`]: ../trait.Serialize.html
|
//! [`Serialize`]: ../trait.Serialize.html
|
||||||
//! [`Serializer`]: ../trait.Serializer.html
|
//! [`Serializer`]: ../trait.Serializer.html
|
||||||
//! [`bincode`]: https://github.com/TyOverby/bincode
|
//! [`bincode`]: https://github.com/servo/bincode
|
||||||
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
|
||||||
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
//! [`serde_derive`]: https://crates.io/crates/serde_derive
|
||||||
//! [`serde_json`]: https://github.com/serde-rs/json
|
//! [`serde_json`]: https://github.com/serde-rs/json
|
||||||
@@ -1278,7 +1278,7 @@ pub trait Serializer: Sized {
|
|||||||
<I as IntoIterator>::Item: Serialize,
|
<I as IntoIterator>::Item: Serialize,
|
||||||
{
|
{
|
||||||
let iter = iter.into_iter();
|
let iter = iter.into_iter();
|
||||||
let mut serializer = try!(self.serialize_seq(iter.len_hint()));
|
let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter)));
|
||||||
for item in iter {
|
for item in iter {
|
||||||
try!(serializer.serialize_element(&item));
|
try!(serializer.serialize_element(&item));
|
||||||
}
|
}
|
||||||
@@ -1318,7 +1318,7 @@ pub trait Serializer: Sized {
|
|||||||
I: IntoIterator<Item = (K, V)>,
|
I: IntoIterator<Item = (K, V)>,
|
||||||
{
|
{
|
||||||
let iter = iter.into_iter();
|
let iter = iter.into_iter();
|
||||||
let mut serializer = try!(self.serialize_map(iter.len_hint()));
|
let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter)));
|
||||||
for (key, value) in iter {
|
for (key, value) in iter {
|
||||||
try!(serializer.serialize_entry(&key, &value));
|
try!(serializer.serialize_entry(&key, &value));
|
||||||
}
|
}
|
||||||
@@ -1953,35 +1953,6 @@ pub trait SerializeStructVariant {
|
|||||||
fn end(self) -> Result<Self::Ok, Self::Error>;
|
fn end(self) -> Result<Self::Ok, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
trait LenHint: Iterator {
|
|
||||||
fn len_hint(&self) -> Option<usize>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I> LenHint for I
|
|
||||||
where
|
|
||||||
I: Iterator,
|
|
||||||
{
|
|
||||||
#[cfg(not(feature = "unstable"))]
|
|
||||||
fn len_hint(&self) -> Option<usize> {
|
|
||||||
iterator_len_hint(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
default fn len_hint(&self) -> Option<usize> {
|
|
||||||
iterator_len_hint(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
impl<I> LenHint for I
|
|
||||||
where
|
|
||||||
I: ExactSizeIterator,
|
|
||||||
{
|
|
||||||
fn len_hint(&self) -> Option<usize> {
|
|
||||||
Some(self.len())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iterator_len_hint<I>(iter: &I) -> Option<usize>
|
fn iterator_len_hint<I>(iter: &I) -> Option<usize>
|
||||||
where
|
where
|
||||||
I: Iterator,
|
I: Iterator,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.113" # remember to update html_root_url
|
version = "1.0.116" # 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 OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
@@ -22,7 +22,7 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "1.0", features = ["visit"] }
|
syn = { version = "1.0.33", features = ["visit"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde = { version = "1.0", path = "../serde" }
|
serde = { version = "1.0", path = "../serde" }
|
||||||
|
|||||||
@@ -597,7 +597,11 @@ impl Container {
|
|||||||
for attr in &item.attrs {
|
for attr in &item.attrs {
|
||||||
if attr.path.is_ident("repr") {
|
if attr.path.is_ident("repr") {
|
||||||
let _ = attr.parse_args_with(|input: ParseStream| {
|
let _ = attr.parse_args_with(|input: ParseStream| {
|
||||||
is_packed |= input.parse::<Ident>()? == "packed";
|
while let Some(token) = input.parse()? {
|
||||||
|
if let TokenTree::Ident(ident) = token {
|
||||||
|
is_packed |= ident == "packed";
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,14 @@
|
|||||||
//!
|
//!
|
||||||
//! [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.113")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.116")]
|
||||||
#![allow(unknown_lints, bare_trait_objects)]
|
#![allow(unknown_lints, bare_trait_objects)]
|
||||||
#![deny(clippy::all, clippy::pedantic)]
|
#![deny(clippy::all, clippy::pedantic)]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
clippy::cognitive_complexity,
|
clippy::cognitive_complexity,
|
||||||
clippy::enum_variant_names,
|
clippy::enum_variant_names,
|
||||||
|
clippy::match_like_matches_macro,
|
||||||
clippy::needless_pass_by_value,
|
clippy::needless_pass_by_value,
|
||||||
clippy::too_many_arguments,
|
clippy::too_many_arguments,
|
||||||
clippy::trivially_copy_pass_by_ref,
|
clippy::trivially_copy_pass_by_ref,
|
||||||
@@ -40,6 +41,7 @@
|
|||||||
clippy::match_same_arms,
|
clippy::match_same_arms,
|
||||||
clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
clippy::must_use_candidate,
|
clippy::must_use_candidate,
|
||||||
|
clippy::option_if_let_else,
|
||||||
clippy::similar_names,
|
clippy::similar_names,
|
||||||
clippy::single_match_else,
|
clippy::single_match_else,
|
||||||
clippy::struct_excessive_bools,
|
clippy::struct_excessive_bools,
|
||||||
@@ -48,8 +50,6 @@
|
|||||||
clippy::use_self,
|
clippy::use_self,
|
||||||
clippy::wildcard_imports
|
clippy::wildcard_imports
|
||||||
)]
|
)]
|
||||||
// The `quote!` macro requires deep recursion.
|
|
||||||
#![recursion_limit = "512"]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate quote;
|
extern crate quote;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ path = "lib.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "1.0", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
syn = { version = "1.0.33", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.113" # remember to update html_root_url
|
version = "1.0.116" # 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 OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.113")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.116")]
|
||||||
#![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))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#[cfg_attr(target_os = "emscripten", ignore)]
|
#[cfg_attr(target_os = "emscripten", ignore)]
|
||||||
#[cfg_attr(not(expandtest), ignore)]
|
#[cfg_attr(not(expandtest), ignore)]
|
||||||
#[rustversion::attr(not(nightly), ignore)]
|
#[rustversion::attr(not(nightly), ignore)]
|
||||||
|
#[allow(unused_attributes)]
|
||||||
#[test]
|
#[test]
|
||||||
fn expandtest() {
|
fn expandtest() {
|
||||||
macrotest::expand("tests/expand/*.rs");
|
macrotest::expand("tests/expand/*.rs");
|
||||||
|
|||||||
@@ -1967,6 +1967,29 @@ fn test_flatten_map_twice() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_flatten_unit() {
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
struct Response<T> {
|
||||||
|
#[serde(flatten)]
|
||||||
|
data: T,
|
||||||
|
status: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_tokens(
|
||||||
|
&Response {
|
||||||
|
data: (),
|
||||||
|
status: 0,
|
||||||
|
},
|
||||||
|
&[
|
||||||
|
Token::Map { len: None },
|
||||||
|
Token::Str("status"),
|
||||||
|
Token::U64(0),
|
||||||
|
Token::MapEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_flatten_unsupported_type() {
|
fn test_flatten_unsupported_type() {
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
#![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)]
|
#![allow(
|
||||||
|
unknown_lints,
|
||||||
|
mixed_script_confusables,
|
||||||
|
clippy::trivially_copy_pass_by_ref
|
||||||
|
)]
|
||||||
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|||||||
@@ -1878,3 +1878,31 @@ fn test_internally_tagged_newtype_variant_containing_unit_struct() {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deny(safe_packed_borrows)]
|
||||||
|
#[test]
|
||||||
|
fn test_packed_struct_can_derive_serialize() {
|
||||||
|
#[derive(Copy, Clone, Serialize)]
|
||||||
|
#[repr(packed, C)]
|
||||||
|
struct PackedC {
|
||||||
|
t: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Serialize)]
|
||||||
|
#[repr(C, packed)]
|
||||||
|
struct CPacked {
|
||||||
|
t: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Serialize)]
|
||||||
|
#[repr(C, packed(2))]
|
||||||
|
struct CPacked2 {
|
||||||
|
t: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Serialize)]
|
||||||
|
#[repr(packed(2), C)]
|
||||||
|
struct Packed2C {
|
||||||
|
t: f32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user