mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-29 11:47:55 +00:00
Compare commits
50 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 | |||
| 7350b58f5c | |||
| 7351e0e55a | |||
| b3ff7e43ef | |||
| a50e1c20e9 | |||
| 6980727d74 | |||
| bb1dedf04d | |||
| f3520e526b | |||
| e8fd2c85c3 | |||
| 97962d51e2 | |||
| 95b1a5d3d9 | |||
| 0856a2c101 | |||
| 9f331cc257 | |||
| ef16c815f6 | |||
| c45a809d5c | |||
| f7d06cae4c | |||
| 31fe82a215 | |||
| ef6ed1d1be | |||
| 9d1251548b | |||
| c20730ee39 | |||
| afd51ef0f4 | |||
| 3167f98689 |
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
name: Help or discussion
|
|
||||||
about: This is the right place
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
+1
-6
@@ -4,11 +4,6 @@ Serde welcomes contribution from everyone in the form of suggestions, bug
|
|||||||
reports, pull requests, and feedback. This document gives some guidance if you
|
reports, pull requests, and feedback. This document gives some guidance if you
|
||||||
are thinking of helping us.
|
are thinking of helping us.
|
||||||
|
|
||||||
Please reach out here in a GitHub issue or in the #serde IRC channel on
|
|
||||||
[`irc.mozilla.org`] if we can do anything to help you contribute.
|
|
||||||
|
|
||||||
[`irc.mozilla.org`]: https://wiki.mozilla.org/IRC
|
|
||||||
|
|
||||||
## Submitting bug reports and feature requests
|
## Submitting bug reports and feature requests
|
||||||
|
|
||||||
Serde development is spread across lots of repositories, but this serde-rs/serde
|
Serde development is spread across lots of repositories, but this serde-rs/serde
|
||||||
@@ -63,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
|
||||||
|
|||||||
@@ -75,13 +75,23 @@ fn main() {
|
|||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|
||||||
Serde developers live in the #serde channel on [`irc.mozilla.org`][irc]. The
|
Serde is one of the most widely used Rust libraries so any place that Rustaceans
|
||||||
\#rust channel is also a good resource with generally faster response time but
|
congregate will be able to help you out. For chat, consider trying the
|
||||||
less specific knowledge about Serde. If IRC is not your thing or you don't get a
|
[#general] or [#beginners] channels of the unofficial community Discord, the
|
||||||
good response, we are happy to respond to [GitHub issues][issues] as well.
|
[#rust-usage] channel of the official Rust Project Discord, or the
|
||||||
|
[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag
|
||||||
|
on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned
|
||||||
|
weekly easy questions post, or the Rust [Discourse forum][discourse]. It's
|
||||||
|
acceptable to file a support issue in this repo but they tend not to get as many
|
||||||
|
eyes as any of the above and may get closed without a response after some time.
|
||||||
|
|
||||||
[irc]: https://wiki.mozilla.org/IRC
|
[#general]: https://discord.com/channels/273534239310479360/274215136414400513
|
||||||
[issues]: https://github.com/serde-rs/serde/issues/new/choose
|
[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281
|
||||||
|
[#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
|
||||||
|
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
|
||||||
|
[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
|
||||||
|
[/r/rust]: https://www.reddit.com/r/rust
|
||||||
|
[discourse]: https://users.rust-lang.org
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|||||||
+16
-6
@@ -43,10 +43,20 @@ fn main() {
|
|||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|
||||||
Serde developers live in the #serde channel on [`irc.mozilla.org`][irc]. The
|
Serde is one of the most widely used Rust libraries so any place that Rustaceans
|
||||||
\#rust channel is also a good resource with generally faster response time but
|
congregate will be able to help you out. For chat, consider trying the
|
||||||
less specific knowledge about Serde. If IRC is not your thing or you don't get a
|
[#general] or [#beginners] channels of the unofficial community Discord, the
|
||||||
good response, we are happy to respond to [GitHub issues][issues] as well.
|
[#rust-usage] channel of the official Rust Project Discord, or the
|
||||||
|
[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag
|
||||||
|
on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned
|
||||||
|
weekly easy questions post, or the Rust [Discourse forum][discourse]. It's
|
||||||
|
acceptable to file a support issue in this repo but they tend not to get as many
|
||||||
|
eyes as any of the above and may get closed without a response after some time.
|
||||||
|
|
||||||
[irc]: https://wiki.mozilla.org/IRC
|
[#general]: https://discord.com/channels/273534239310479360/274215136414400513
|
||||||
[issues]: https://github.com/serde-rs/serde/issues/new/choose
|
[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281
|
||||||
|
[#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848
|
||||||
|
[zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general
|
||||||
|
[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
|
||||||
|
[/r/rust]: https://www.reddit.com/r/rust
|
||||||
|
[discourse]: https://users.rust-lang.org
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
error_on_line_overflow = false
|
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.110" # 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"
|
||||||
@@ -10,11 +10,11 @@ documentation = "https://docs.serde.rs/serde/"
|
|||||||
keywords = ["serde", "serialization", "no_std"]
|
keywords = ["serde", "serialization", "no_std"]
|
||||||
categories = ["encoding"]
|
categories = ["encoding"]
|
||||||
readme = "crates-io.md"
|
readme = "crates-io.md"
|
||||||
include = ["Cargo.toml", "build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.110", 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" }
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Non-zero integers stabilized in Rust 1.28:
|
// Non-zero integers stabilized in Rust 1.28:
|
||||||
// https://github.com/rust-lang/rust/pull/50808
|
// https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#library-stabilizations
|
||||||
if minor >= 28 {
|
if minor >= 28 {
|
||||||
println!("cargo:rustc-cfg=num_nonzero");
|
println!("cargo:rustc-cfg=num_nonzero");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
+17
-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,14 +48,18 @@
|
|||||||
//! 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
|
||||||
//! Rust structs. *(deserialization only)*
|
//! Rust structs. *(deserialization only)*
|
||||||
|
//! - [S-expressions], the textual representation of code and data used by the
|
||||||
|
//! Lisp language family.
|
||||||
|
//! - [D-Bus]'s binary wire 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
|
||||||
@@ -66,23 +70,26 @@
|
|||||||
//! [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
|
||||||
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
|
//! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
|
||||||
|
//! [S-expressions]: https://github.com/rotty/lexpr-rs
|
||||||
|
//! [D-Bus]: https://docs.rs/zvariant
|
||||||
|
//! [FlexBuffers]: https://github.com/google/flatbuffers/tree/master/rust/flexbuffers
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// 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.110")]
|
#![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))]
|
||||||
@@ -90,6 +97,8 @@
|
|||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
allow(
|
allow(
|
||||||
|
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
|
||||||
|
unnested_or_patterns,
|
||||||
// not available in our oldest supported compiler
|
// not available in our oldest supported compiler
|
||||||
checked_conversions,
|
checked_conversions,
|
||||||
empty_enum,
|
empty_enum,
|
||||||
@@ -102,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,
|
||||||
|
|||||||
@@ -1562,7 +1562,7 @@ mod content {
|
|||||||
other.unexpected(),
|
other.unexpected(),
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
_ => Err(de::Error::invalid_type(
|
None => Err(de::Error::invalid_type(
|
||||||
de::Unexpected::UnitVariant,
|
de::Unexpected::UnitVariant,
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
@@ -2252,7 +2252,7 @@ mod content {
|
|||||||
other.unexpected(),
|
other.unexpected(),
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
_ => Err(de::Error::invalid_type(
|
None => Err(de::Error::invalid_type(
|
||||||
de::Unexpected::UnitVariant,
|
de::Unexpected::UnitVariant,
|
||||||
&"struct variant",
|
&"struct variant",
|
||||||
)),
|
)),
|
||||||
@@ -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> {
|
||||||
@@ -1243,6 +1243,18 @@ where
|
|||||||
self.0.serialize_value(value)
|
self.0.serialize_value(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn serialize_entry<K: ?Sized, V: ?Sized>(
|
||||||
|
&mut self,
|
||||||
|
key: &K,
|
||||||
|
value: &V,
|
||||||
|
) -> Result<(), Self::Error>
|
||||||
|
where
|
||||||
|
K: Serialize,
|
||||||
|
V: Serialize,
|
||||||
|
{
|
||||||
|
self.0.serialize_entry(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<(), Self::Error> {
|
fn end(self) -> Result<(), Self::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
+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.110" # 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)]"
|
||||||
@@ -9,7 +9,7 @@ repository = "https://github.com/serde-rs/serde"
|
|||||||
documentation = "https://serde.rs/derive.html"
|
documentation = "https://serde.rs/derive.html"
|
||||||
keywords = ["serde", "serialization", "no_std"]
|
keywords = ["serde", "serialization", "no_std"]
|
||||||
readme = "crates-io.md"
|
readme = "crates-io.md"
|
||||||
include = ["Cargo.toml", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
@@ -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" }
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::process::Command;
|
||||||
|
use std::str;
|
||||||
|
|
||||||
|
// The rustc-cfg strings below are *not* public API. Please let us know by
|
||||||
|
// opening a GitHub issue if your build environment requires some way to enable
|
||||||
|
// these cfgs other than by executing our build script.
|
||||||
|
fn main() {
|
||||||
|
let minor = match rustc_minor_version() {
|
||||||
|
Some(minor) => minor,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Underscore const names stabilized in Rust 1.37:
|
||||||
|
// https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html#using-unnamed-const-items-for-macros
|
||||||
|
if minor >= 37 {
|
||||||
|
println!("cargo:rustc-cfg=underscore_consts");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rustc_minor_version() -> Option<u32> {
|
||||||
|
let rustc = env::var_os("RUSTC")?;
|
||||||
|
let output = Command::new(rustc).arg("--version").output().ok()?;
|
||||||
|
let version = str::from_utf8(&output.stdout).ok()?;
|
||||||
|
let mut pieces = version.split('.');
|
||||||
|
if pieces.next() != Some("rustc 1") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
pieces.next()?.parse().ok()
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ use syn::punctuated::{Pair, Punctuated};
|
|||||||
use syn::visit::{self, Visit};
|
use syn::visit::{self, Visit};
|
||||||
|
|
||||||
use internals::ast::{Container, Data};
|
use internals::ast::{Container, Data};
|
||||||
use internals::attr;
|
use internals::{attr, ungroup};
|
||||||
|
|
||||||
use proc_macro2::Span;
|
use proc_macro2::Span;
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ pub fn with_bound(
|
|||||||
}
|
}
|
||||||
impl<'ast> Visit<'ast> for FindTyParams<'ast> {
|
impl<'ast> Visit<'ast> for FindTyParams<'ast> {
|
||||||
fn visit_field(&mut self, field: &'ast syn::Field) {
|
fn visit_field(&mut self, field: &'ast syn::Field) {
|
||||||
if let syn::Type::Path(ty) = &field.ty {
|
if let syn::Type::Path(ty) = ungroup(&field.ty) {
|
||||||
if let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next() {
|
if let Some(Pair::Punctuated(t, _)) = ty.path.segments.pairs().next() {
|
||||||
if self.all_type_params.contains(&t.ident) {
|
if self.all_type_params.contains(&t.ident) {
|
||||||
self.associated_type_usage.push(ty);
|
self.associated_type_usage.push(ty);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use bound;
|
|||||||
use dummy;
|
use dummy;
|
||||||
use fragment::{Expr, Fragment, Match, Stmts};
|
use fragment::{Expr, Fragment, Match, Stmts};
|
||||||
use internals::ast::{Container, Data, Field, Style, Variant};
|
use internals::ast::{Container, Data, Field, Style, Variant};
|
||||||
use internals::{attr, Ctxt, Derive};
|
use internals::{attr, ungroup, Ctxt, Derive};
|
||||||
use pretend;
|
use pretend;
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
@@ -77,7 +77,7 @@ fn precondition(cx: &Ctxt, cont: &Container) {
|
|||||||
fn precondition_sized(cx: &Ctxt, cont: &Container) {
|
fn precondition_sized(cx: &Ctxt, cont: &Container) {
|
||||||
if let Data::Struct(_, fields) = &cont.data {
|
if let Data::Struct(_, fields) = &cont.data {
|
||||||
if let Some(last) = fields.last() {
|
if let Some(last) = fields.last() {
|
||||||
if let syn::Type::Slice(_) = *last.ty {
|
if let syn::Type::Slice(_) = ungroup(last.ty) {
|
||||||
cx.error_spanned_by(
|
cx.error_spanned_by(
|
||||||
cont.original,
|
cont.original,
|
||||||
"cannot deserialize a dynamically sized struct",
|
"cannot deserialize a dynamically sized struct",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use proc_macro2::{Ident, Span, TokenStream};
|
use proc_macro2::{Ident, TokenStream};
|
||||||
|
use quote::format_ident;
|
||||||
|
|
||||||
use syn;
|
use syn;
|
||||||
use try;
|
use try;
|
||||||
@@ -11,10 +12,11 @@ pub fn wrap_in_const(
|
|||||||
) -> TokenStream {
|
) -> TokenStream {
|
||||||
let try_replacement = try::replacement();
|
let try_replacement = try::replacement();
|
||||||
|
|
||||||
let dummy_const = Ident::new(
|
let dummy_const = if cfg!(underscore_consts) {
|
||||||
&format!("_IMPL_{}_FOR_{}", trait_, unraw(ty)),
|
format_ident!("_")
|
||||||
Span::call_site(),
|
} else {
|
||||||
);
|
format_ident!("_IMPL_{}_FOR_{}", trait_, unraw(ty))
|
||||||
|
};
|
||||||
|
|
||||||
let use_serde = match serde_path {
|
let use_serde = match serde_path {
|
||||||
Some(path) => quote! {
|
Some(path) => quote! {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use internals::symbol::*;
|
use internals::symbol::*;
|
||||||
use internals::Ctxt;
|
use internals::{ungroup, Ctxt};
|
||||||
use proc_macro2::{Group, Span, TokenStream, TokenTree};
|
use proc_macro2::{Group, Span, TokenStream, TokenTree};
|
||||||
use quote::ToTokens;
|
use quote::ToTokens;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
@@ -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(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1737,7 +1741,7 @@ fn is_implicitly_borrowed_reference(ty: &syn::Type) -> bool {
|
|||||||
// cow: Cow<'a, str>,
|
// cow: Cow<'a, str>,
|
||||||
// }
|
// }
|
||||||
fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||||
let path = match ty {
|
let path = match ungroup(ty) {
|
||||||
syn::Type::Path(ty) => &ty.path,
|
syn::Type::Path(ty) => &ty.path,
|
||||||
_ => {
|
_ => {
|
||||||
return false;
|
return false;
|
||||||
@@ -1764,7 +1768,7 @@ fn is_cow(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||||
let path = match ty {
|
let path = match ungroup(ty) {
|
||||||
syn::Type::Path(ty) => &ty.path,
|
syn::Type::Path(ty) => &ty.path,
|
||||||
_ => {
|
_ => {
|
||||||
return false;
|
return false;
|
||||||
@@ -1811,7 +1815,7 @@ fn is_option(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
|||||||
// r: &'a str,
|
// r: &'a str,
|
||||||
// }
|
// }
|
||||||
fn is_reference(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
fn is_reference(ty: &syn::Type, elem: fn(&syn::Type) -> bool) -> bool {
|
||||||
match ty {
|
match ungroup(ty) {
|
||||||
syn::Type::Reference(ty) => ty.mutability.is_none() && elem(&ty.elem),
|
syn::Type::Reference(ty) => ty.mutability.is_none() && elem(&ty.elem),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
@@ -1822,14 +1826,14 @@ fn is_str(ty: &syn::Type) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_slice_u8(ty: &syn::Type) -> bool {
|
fn is_slice_u8(ty: &syn::Type) -> bool {
|
||||||
match ty {
|
match ungroup(ty) {
|
||||||
syn::Type::Slice(ty) => is_primitive_type(&ty.elem, "u8"),
|
syn::Type::Slice(ty) => is_primitive_type(&ty.elem, "u8"),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_primitive_type(ty: &syn::Type, primitive: &str) -> bool {
|
fn is_primitive_type(ty: &syn::Type, primitive: &str) -> bool {
|
||||||
match ty {
|
match ungroup(ty) {
|
||||||
syn::Type::Path(ty) => ty.qself.is_none() && is_primitive_path(&ty.path, primitive),
|
syn::Type::Path(ty) => ty.qself.is_none() && is_primitive_path(&ty.path, primitive),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use internals::ast::{Container, Data, Field, Style};
|
use internals::ast::{Container, Data, Field, Style};
|
||||||
use internals::attr::{Identifier, TagType};
|
use internals::attr::{Identifier, TagType};
|
||||||
use internals::{Ctxt, Derive};
|
use internals::{ungroup, Ctxt, Derive};
|
||||||
use syn::{Member, Type};
|
use syn::{Member, Type};
|
||||||
|
|
||||||
/// Cross-cutting checks that require looking at more than a single attrs
|
/// Cross-cutting checks that require looking at more than a single attrs
|
||||||
@@ -396,7 +396,7 @@ fn member_message(member: &Member) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn allow_transparent(field: &Field, derive: Derive) -> bool {
|
fn allow_transparent(field: &Field, derive: Derive) -> bool {
|
||||||
if let Type::Path(ty) = field.ty {
|
if let Type::Path(ty) = ungroup(&field.ty) {
|
||||||
if let Some(seg) = ty.path.segments.last() {
|
if let Some(seg) = ty.path.segments.last() {
|
||||||
if seg.ident == "PhantomData" {
|
if seg.ident == "PhantomData" {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -8,8 +8,17 @@ mod case;
|
|||||||
mod check;
|
mod check;
|
||||||
mod symbol;
|
mod symbol;
|
||||||
|
|
||||||
|
use syn::Type;
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub enum Derive {
|
pub enum Derive {
|
||||||
Serialize,
|
Serialize,
|
||||||
Deserialize,
|
Deserialize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ungroup(mut ty: &Type) -> &Type {
|
||||||
|
while let Type::Group(group) = ty {
|
||||||
|
ty = &group.elem;
|
||||||
|
}
|
||||||
|
ty
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,18 +13,21 @@
|
|||||||
//!
|
//!
|
||||||
//! [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.110")]
|
#![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,
|
||||||
clippy::used_underscore_binding,
|
clippy::used_underscore_binding,
|
||||||
clippy::wildcard_in_or_patterns
|
clippy::wildcard_in_or_patterns,
|
||||||
|
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
|
||||||
|
clippy::unnested_or_patterns,
|
||||||
)]
|
)]
|
||||||
// Ignored clippy_pedantic lints
|
// Ignored clippy_pedantic lints
|
||||||
#![allow(
|
#![allow(
|
||||||
@@ -38,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,
|
||||||
@@ -46,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;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ homepage = "https://serde.rs"
|
|||||||
repository = "https://github.com/serde-rs/serde"
|
repository = "https://github.com/serde-rs/serde"
|
||||||
documentation = "https://docs.rs/serde_derive_internals"
|
documentation = "https://docs.rs/serde_derive_internals"
|
||||||
keywords = ["serde", "serialization"]
|
keywords = ["serde", "serialization"]
|
||||||
include = ["Cargo.toml", "lib.rs", "src/**/*.rs", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["lib.rs", "src/**/*.rs", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
@@ -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"]
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
cognitive_complexity,
|
cognitive_complexity,
|
||||||
redundant_field_names,
|
redundant_field_names,
|
||||||
trivially_copy_pass_by_ref,
|
trivially_copy_pass_by_ref,
|
||||||
wildcard_in_or_patterns
|
wildcard_in_or_patterns,
|
||||||
|
// clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
|
||||||
|
unnested_or_patterns,
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.110" # 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"
|
||||||
@@ -9,7 +9,7 @@ repository = "https://github.com/serde-rs/serde"
|
|||||||
documentation = "https://docs.serde.rs/serde_test/"
|
documentation = "https://docs.serde.rs/serde_test/"
|
||||||
keywords = ["serde", "serialization"]
|
keywords = ["serde", "serialization"]
|
||||||
readme = "crates-io.md"
|
readme = "crates-io.md"
|
||||||
include = ["Cargo.toml", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0.60", path = "../serde" }
|
serde = { version = "1.0.60", path = "../serde" }
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.110")]
|
#![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
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ enum DeEnum<B, C, D> {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_DeEnum: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -261,7 +261,7 @@ const _IMPL_SERIALIZE_FOR_DeEnum: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DeEnum: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct DefaultTyParam<T: AssociatedType<X = i32> = i32> {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_DefaultTyParam: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -45,7 +45,7 @@ const _IMPL_SERIALIZE_FOR_DefaultTyParam: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DefaultTyParam: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ pub enum GenericEnum<T, U> {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_GenericEnum: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -110,7 +110,7 @@ const _IMPL_SERIALIZE_FOR_GenericEnum: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericEnum: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ pub struct GenericStruct<T> {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -38,7 +38,7 @@ const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericStruct: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -400,7 +400,7 @@ const _IMPL_DESERIALIZE_FOR_GenericStruct: () = {
|
|||||||
pub struct GenericNewTypeStruct<T>(T);
|
pub struct GenericNewTypeStruct<T>(T);
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_GenericNewTypeStruct: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -422,7 +422,7 @@ const _IMPL_SERIALIZE_FOR_GenericNewTypeStruct: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericNewTypeStruct: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
pub struct GenericTupleStruct<T, U>(T, U);
|
pub struct GenericTupleStruct<T, U>(T, U);
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_GenericTupleStruct: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ enum Lifetimes<'a> {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_Lifetimes: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -91,7 +91,7 @@ const _IMPL_SERIALIZE_FOR_Lifetimes: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_Lifetimes: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ struct SerNamedMap<'a, 'b, A: 'a, B: 'b, C> {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_SerNamedMap: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -59,7 +59,7 @@ struct DeNamedMap<A, B, C> {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DeNamedMap: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
|
struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_SerNamedTuple: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -51,7 +51,7 @@ const _IMPL_SERIALIZE_FOR_SerNamedTuple: () = {
|
|||||||
struct DeNamedTuple<A, B, C>(A, B, C);
|
struct DeNamedTuple<A, B, C>(A, B, C);
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_DeNamedTuple: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
struct NamedUnit;
|
struct NamedUnit;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_NamedUnit: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -17,7 +17,7 @@ const _IMPL_SERIALIZE_FOR_NamedUnit: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_NamedUnit: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ where
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_SerEnum: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
enum Void {}
|
enum Void {}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_SERIALIZE_FOR_Void: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
@@ -17,7 +17,7 @@ const _IMPL_SERIALIZE_FOR_Void: () = {
|
|||||||
};
|
};
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
const _IMPL_DESERIALIZE_FOR_Void: () = {
|
const _: () = {
|
||||||
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
||||||
extern crate serde as _serde;
|
extern crate serde as _serde;
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
|
|||||||
@@ -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};
|
||||||
@@ -708,6 +712,17 @@ fn test_gen() {
|
|||||||
x: u8,
|
x: u8,
|
||||||
y: u16,
|
y: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! deriving {
|
||||||
|
($field:ty) => {
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct MacroRules<'a> {
|
||||||
|
field: $field,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
deriving!(&'a str);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -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