mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-16 09:01:03 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 48479e4bae | |||
| dfaf48bc09 | |||
| dcbc3e0162 | |||
| 0289d31724 | |||
| 015e39776f | |||
| 6a9a21f178 | |||
| 81ac54b20d | |||
| 6b4e75520a | |||
| b053b4f492 | |||
| c0ba323166 | |||
| 20a48c9580 | |||
| 09938803af | |||
| 6d0b43a220 | |||
| 8a4dfa7231 | |||
| 2c1f62d4b4 |
@@ -3,6 +3,7 @@ name: CI
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
schedule: [cron: "40 1 * * *"]
|
schedule: [cron: "40 1 * * *"]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
msrv = "1.13.0"
|
|
||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.164" # remember to update html_root_url and serde_derive dependency
|
version = "1.0.166" # 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>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
categories = ["encoding", "no-std"]
|
categories = ["encoding", "no-std", "no-std::no-alloc"]
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
documentation = "https://docs.rs/serde"
|
documentation = "https://docs.rs/serde"
|
||||||
homepage = "https://serde.rs"
|
homepage = "https://serde.rs"
|
||||||
@@ -15,7 +15,7 @@ repository = "https://github.com/serde-rs/serde"
|
|||||||
rust-version = "1.19"
|
rust-version = "1.19"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.164", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "=1.0.166", 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" }
|
||||||
|
|||||||
+9
-11
@@ -1587,7 +1587,7 @@ macro_rules! parse_socket_impl {
|
|||||||
if deserializer.is_human_readable() {
|
if deserializer.is_human_readable() {
|
||||||
deserializer.deserialize_str(FromStrVisitor::new($expecting))
|
deserializer.deserialize_str(FromStrVisitor::new($expecting))
|
||||||
} else {
|
} else {
|
||||||
<(_, u16)>::deserialize(deserializer).map(|(ip, port)| $new(ip, port))
|
<(_, u16)>::deserialize(deserializer).map($new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1614,12 +1614,10 @@ impl<'de> Deserialize<'de> for net::SocketAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
parse_socket_impl!("IPv4 socket address" net::SocketAddrV4, net::SocketAddrV4::new);
|
parse_socket_impl!("IPv4 socket address" net::SocketAddrV4, |(ip, port)| net::SocketAddrV4::new(ip, port));
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
parse_socket_impl!("IPv6 socket address" net::SocketAddrV6, |ip, port| net::SocketAddrV6::new(
|
parse_socket_impl!("IPv6 socket address" net::SocketAddrV6, |(ip, port)| net::SocketAddrV6::new(ip, port, 0, 0));
|
||||||
ip, port, 0, 0
|
|
||||||
));
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -2098,7 +2096,7 @@ impl<'de> Deserialize<'de> for Duration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const FIELDS: &'static [&'static str] = &["secs", "nanos"];
|
const FIELDS: &[&str] = &["secs", "nanos"];
|
||||||
deserializer.deserialize_struct("Duration", FIELDS, DurationVisitor)
|
deserializer.deserialize_struct("Duration", FIELDS, DurationVisitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2240,7 +2238,7 @@ impl<'de> Deserialize<'de> for SystemTime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"];
|
const FIELDS: &[&str] = &["secs_since_epoch", "nanos_since_epoch"];
|
||||||
let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
|
let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
|
||||||
#[cfg(not(no_systemtime_checked_add))]
|
#[cfg(not(no_systemtime_checked_add))]
|
||||||
let ret = UNIX_EPOCH
|
let ret = UNIX_EPOCH
|
||||||
@@ -2308,7 +2306,7 @@ mod range {
|
|||||||
|
|
||||||
use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
|
use de::{Deserialize, Deserializer, Error, MapAccess, SeqAccess, Visitor};
|
||||||
|
|
||||||
pub const FIELDS: &'static [&'static str] = &["start", "end"];
|
pub const FIELDS: &[&str] = &["start", "end"];
|
||||||
|
|
||||||
// If this were outside of the serde crate, it would just use:
|
// If this were outside of the serde crate, it would just use:
|
||||||
//
|
//
|
||||||
@@ -2534,7 +2532,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VARIANTS: &'static [&'static str] = &["Unbounded", "Included", "Excluded"];
|
const VARIANTS: &[&str] = &["Unbounded", "Included", "Excluded"];
|
||||||
|
|
||||||
deserializer.deserialize_enum("Bound", VARIANTS, BoundVisitor(PhantomData))
|
deserializer.deserialize_enum("Bound", VARIANTS, BoundVisitor(PhantomData))
|
||||||
}
|
}
|
||||||
@@ -2642,7 +2640,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VARIANTS: &'static [&'static str] = &["Ok", "Err"];
|
const VARIANTS: &[&str] = &["Ok", "Err"];
|
||||||
|
|
||||||
deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData))
|
deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData))
|
||||||
}
|
}
|
||||||
@@ -2708,7 +2706,7 @@ struct FromStrVisitor<T> {
|
|||||||
impl<T> FromStrVisitor<T> {
|
impl<T> FromStrVisitor<T> {
|
||||||
fn new(expecting: &'static str) -> Self {
|
fn new(expecting: &'static str) -> Self {
|
||||||
FromStrVisitor {
|
FromStrVisitor {
|
||||||
expecting: expecting,
|
expecting,
|
||||||
ty: PhantomData,
|
ty: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub fn encode(c: char) -> Encode {
|
|||||||
buf[3] = (code & 0x3F) as u8 | TAG_CONT;
|
buf[3] = (code & 0x3F) as u8 | TAG_CONT;
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
Encode { buf: buf, pos: pos }
|
Encode { buf, pos }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Encode {
|
pub struct Encode {
|
||||||
|
|||||||
+14
-18
@@ -251,7 +251,7 @@ macro_rules! primitive_deserializer {
|
|||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn new(value: $ty) -> Self {
|
pub fn new(value: $ty) -> Self {
|
||||||
$name {
|
$name {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +330,7 @@ impl<E> U32Deserializer<E> {
|
|||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn new(value: u32) -> Self {
|
pub fn new(value: u32) -> Self {
|
||||||
U32Deserializer {
|
U32Deserializer {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,7 +419,7 @@ impl<'a, E> StrDeserializer<'a, E> {
|
|||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn new(value: &'a str) -> Self {
|
pub fn new(value: &'a str) -> Self {
|
||||||
StrDeserializer {
|
StrDeserializer {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -498,7 +498,7 @@ impl<'de, E> BorrowedStrDeserializer<'de, E> {
|
|||||||
/// Create a new borrowed deserializer from the given string.
|
/// Create a new borrowed deserializer from the given string.
|
||||||
pub fn new(value: &'de str) -> BorrowedStrDeserializer<'de, E> {
|
pub fn new(value: &'de str) -> BorrowedStrDeserializer<'de, E> {
|
||||||
BorrowedStrDeserializer {
|
BorrowedStrDeserializer {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,7 +598,7 @@ impl<E> StringDeserializer<E> {
|
|||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn new(value: String) -> Self {
|
pub fn new(value: String) -> Self {
|
||||||
StringDeserializer {
|
StringDeserializer {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -701,7 +701,7 @@ impl<'a, E> CowStrDeserializer<'a, E> {
|
|||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn new(value: Cow<'a, str>) -> Self {
|
pub fn new(value: Cow<'a, str>) -> Self {
|
||||||
CowStrDeserializer {
|
CowStrDeserializer {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -783,7 +783,7 @@ impl<'a, E> BytesDeserializer<'a, E> {
|
|||||||
/// Create a new deserializer from the given bytes.
|
/// Create a new deserializer from the given bytes.
|
||||||
pub fn new(value: &'a [u8]) -> Self {
|
pub fn new(value: &'a [u8]) -> Self {
|
||||||
BytesDeserializer {
|
BytesDeserializer {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -842,7 +842,7 @@ impl<'de, E> BorrowedBytesDeserializer<'de, E> {
|
|||||||
/// Create a new borrowed deserializer from the given borrowed bytes.
|
/// Create a new borrowed deserializer from the given borrowed bytes.
|
||||||
pub fn new(value: &'de [u8]) -> Self {
|
pub fn new(value: &'de [u8]) -> Self {
|
||||||
BorrowedBytesDeserializer {
|
BorrowedBytesDeserializer {
|
||||||
value: value,
|
value,
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1053,7 +1053,7 @@ pub struct SeqAccessDeserializer<A> {
|
|||||||
impl<A> SeqAccessDeserializer<A> {
|
impl<A> SeqAccessDeserializer<A> {
|
||||||
/// Construct a new `SeqAccessDeserializer<A>`.
|
/// Construct a new `SeqAccessDeserializer<A>`.
|
||||||
pub fn new(seq: A) -> Self {
|
pub fn new(seq: A) -> Self {
|
||||||
SeqAccessDeserializer { seq: seq }
|
SeqAccessDeserializer { seq }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1454,7 +1454,7 @@ pub struct MapAccessDeserializer<A> {
|
|||||||
impl<A> MapAccessDeserializer<A> {
|
impl<A> MapAccessDeserializer<A> {
|
||||||
/// Construct a new `MapAccessDeserializer<A>`.
|
/// Construct a new `MapAccessDeserializer<A>`.
|
||||||
pub fn new(map: A) -> Self {
|
pub fn new(map: A) -> Self {
|
||||||
MapAccessDeserializer { map: map }
|
MapAccessDeserializer { map }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1519,7 +1519,7 @@ pub struct EnumAccessDeserializer<A> {
|
|||||||
impl<A> EnumAccessDeserializer<A> {
|
impl<A> EnumAccessDeserializer<A> {
|
||||||
/// Construct a new `EnumAccessDeserializer<A>`.
|
/// Construct a new `EnumAccessDeserializer<A>`.
|
||||||
pub fn new(access: A) -> Self {
|
pub fn new(access: A) -> Self {
|
||||||
EnumAccessDeserializer { access: access }
|
EnumAccessDeserializer { access }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1613,7 +1613,7 @@ mod private {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_as_enum<A>(map: A) -> MapAsEnum<A> {
|
pub fn map_as_enum<A>(map: A) -> MapAsEnum<A> {
|
||||||
MapAsEnum { map: map }
|
MapAsEnum { map }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de, A> VariantAccess<'de> for MapAsEnum<A>
|
impl<'de, A> VariantAccess<'de> for MapAsEnum<A>
|
||||||
@@ -1637,10 +1637,7 @@ mod private {
|
|||||||
where
|
where
|
||||||
V: Visitor<'de>,
|
V: Visitor<'de>,
|
||||||
{
|
{
|
||||||
self.map.next_value_seed(SeedTupleVariant {
|
self.map.next_value_seed(SeedTupleVariant { len, visitor })
|
||||||
len: len,
|
|
||||||
visitor: visitor,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn struct_variant<V>(
|
fn struct_variant<V>(
|
||||||
@@ -1651,8 +1648,7 @@ mod private {
|
|||||||
where
|
where
|
||||||
V: Visitor<'de>,
|
V: Visitor<'de>,
|
||||||
{
|
{
|
||||||
self.map
|
self.map.next_value_seed(SeedStructVariant { visitor })
|
||||||
.next_value_seed(SeedStructVariant { visitor: visitor })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -93,7 +93,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.164")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.166")]
|
||||||
// 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
|
||||||
|
|||||||
+16
-16
@@ -518,7 +518,7 @@ mod content {
|
|||||||
impl<'de> TagOrContentVisitor<'de> {
|
impl<'de> TagOrContentVisitor<'de> {
|
||||||
fn new(name: &'static str) -> Self {
|
fn new(name: &'static str) -> Self {
|
||||||
TagOrContentVisitor {
|
TagOrContentVisitor {
|
||||||
name: name,
|
name,
|
||||||
value: PhantomData,
|
value: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -815,7 +815,7 @@ mod content {
|
|||||||
pub fn new(name: &'static str, expecting: &'static str) -> Self {
|
pub fn new(name: &'static str, expecting: &'static str) -> Self {
|
||||||
TaggedContentVisitor {
|
TaggedContentVisitor {
|
||||||
tag_name: name,
|
tag_name: name,
|
||||||
expecting: expecting,
|
expecting,
|
||||||
value: PhantomData,
|
value: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -859,7 +859,7 @@ mod content {
|
|||||||
};
|
};
|
||||||
let rest = de::value::SeqAccessDeserializer::new(seq);
|
let rest = de::value::SeqAccessDeserializer::new(seq);
|
||||||
Ok(TaggedContent {
|
Ok(TaggedContent {
|
||||||
tag: tag,
|
tag,
|
||||||
content: try!(Content::deserialize(rest)),
|
content: try!(Content::deserialize(rest)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -887,7 +887,7 @@ mod content {
|
|||||||
match tag {
|
match tag {
|
||||||
None => Err(de::Error::missing_field(self.tag_name)),
|
None => Err(de::Error::missing_field(self.tag_name)),
|
||||||
Some(tag) => Ok(TaggedContent {
|
Some(tag) => Ok(TaggedContent {
|
||||||
tag: tag,
|
tag,
|
||||||
content: Content::Map(vec),
|
content: Content::Map(vec),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
@@ -1464,7 +1464,7 @@ mod content {
|
|||||||
/// private API, don't use
|
/// private API, don't use
|
||||||
pub fn new(content: Content<'de>) -> Self {
|
pub fn new(content: Content<'de>) -> Self {
|
||||||
ContentDeserializer {
|
ContentDeserializer {
|
||||||
content: content,
|
content,
|
||||||
err: PhantomData,
|
err: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1485,8 +1485,8 @@ mod content {
|
|||||||
{
|
{
|
||||||
pub fn new(variant: Content<'de>, value: Option<Content<'de>>) -> EnumDeserializer<'de, E> {
|
pub fn new(variant: Content<'de>, value: Option<Content<'de>>) -> EnumDeserializer<'de, E> {
|
||||||
EnumDeserializer {
|
EnumDeserializer {
|
||||||
variant: variant,
|
variant,
|
||||||
value: value,
|
value,
|
||||||
err: PhantomData,
|
err: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2142,8 +2142,8 @@ mod content {
|
|||||||
};
|
};
|
||||||
|
|
||||||
visitor.visit_enum(EnumRefDeserializer {
|
visitor.visit_enum(EnumRefDeserializer {
|
||||||
variant: variant,
|
variant,
|
||||||
value: value,
|
value,
|
||||||
err: PhantomData,
|
err: PhantomData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -2187,7 +2187,7 @@ mod content {
|
|||||||
/// private API, don't use
|
/// private API, don't use
|
||||||
pub fn new(content: &'a Content<'de>) -> Self {
|
pub fn new(content: &'a Content<'de>) -> Self {
|
||||||
ContentRefDeserializer {
|
ContentRefDeserializer {
|
||||||
content: content,
|
content,
|
||||||
err: PhantomData,
|
err: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2496,8 +2496,8 @@ mod content {
|
|||||||
/// Not public API.
|
/// Not public API.
|
||||||
pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
|
pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
|
||||||
InternallyTaggedUnitVisitor {
|
InternallyTaggedUnitVisitor {
|
||||||
type_name: type_name,
|
type_name,
|
||||||
variant_name: variant_name,
|
variant_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2541,8 +2541,8 @@ mod content {
|
|||||||
/// Not public API.
|
/// Not public API.
|
||||||
pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
|
pub fn new(type_name: &'a str, variant_name: &'a str) -> Self {
|
||||||
UntaggedUnitVisitor {
|
UntaggedUnitVisitor {
|
||||||
type_name: type_name,
|
type_name,
|
||||||
variant_name: variant_name,
|
variant_name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2758,7 +2758,7 @@ where
|
|||||||
where
|
where
|
||||||
V: Visitor<'de>,
|
V: Visitor<'de>,
|
||||||
{
|
{
|
||||||
for entry in self.0.iter_mut() {
|
for entry in self.0 {
|
||||||
if let Some((key, value)) = flat_map_take_entry(entry, variants) {
|
if let Some((key, value)) = flat_map_take_entry(entry, variants) {
|
||||||
return visitor.visit_enum(EnumDeserializer::new(key, Some(value)));
|
return visitor.visit_enum(EnumDeserializer::new(key, Some(value)));
|
||||||
}
|
}
|
||||||
@@ -2793,7 +2793,7 @@ where
|
|||||||
visitor.visit_map(FlatStructAccess {
|
visitor.visit_map(FlatStructAccess {
|
||||||
iter: self.0.iter_mut(),
|
iter: self.0.iter_mut(),
|
||||||
pending_content: None,
|
pending_content: None,
|
||||||
fields: fields,
|
fields,
|
||||||
_marker: PhantomData,
|
_marker: PhantomData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-18
@@ -27,10 +27,10 @@ where
|
|||||||
T: Serialize,
|
T: Serialize,
|
||||||
{
|
{
|
||||||
value.serialize(TaggedSerializer {
|
value.serialize(TaggedSerializer {
|
||||||
type_ident: type_ident,
|
type_ident,
|
||||||
variant_ident: variant_ident,
|
variant_ident,
|
||||||
tag: tag,
|
tag,
|
||||||
variant_name: variant_name,
|
variant_name,
|
||||||
delegate: serializer,
|
delegate: serializer,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -350,8 +350,8 @@ mod content {
|
|||||||
impl<M> SerializeTupleVariantAsMapValue<M> {
|
impl<M> SerializeTupleVariantAsMapValue<M> {
|
||||||
pub fn new(map: M, name: &'static str, len: usize) -> Self {
|
pub fn new(map: M, name: &'static str, len: usize) -> Self {
|
||||||
SerializeTupleVariantAsMapValue {
|
SerializeTupleVariantAsMapValue {
|
||||||
map: map,
|
map,
|
||||||
name: name,
|
name,
|
||||||
fields: Vec::with_capacity(len),
|
fields: Vec::with_capacity(len),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,8 +390,8 @@ mod content {
|
|||||||
impl<M> SerializeStructVariantAsMapValue<M> {
|
impl<M> SerializeStructVariantAsMapValue<M> {
|
||||||
pub fn new(map: M, name: &'static str, len: usize) -> Self {
|
pub fn new(map: M, name: &'static str, len: usize) -> Self {
|
||||||
SerializeStructVariantAsMapValue {
|
SerializeStructVariantAsMapValue {
|
||||||
map: map,
|
map,
|
||||||
name: name,
|
name,
|
||||||
fields: Vec::with_capacity(len),
|
fields: Vec::with_capacity(len),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -711,7 +711,7 @@ mod content {
|
|||||||
len: usize,
|
len: usize,
|
||||||
) -> Result<Self::SerializeTupleStruct, E> {
|
) -> Result<Self::SerializeTupleStruct, E> {
|
||||||
Ok(SerializeTupleStruct {
|
Ok(SerializeTupleStruct {
|
||||||
name: name,
|
name,
|
||||||
fields: Vec::with_capacity(len),
|
fields: Vec::with_capacity(len),
|
||||||
error: PhantomData,
|
error: PhantomData,
|
||||||
})
|
})
|
||||||
@@ -725,9 +725,9 @@ mod content {
|
|||||||
len: usize,
|
len: usize,
|
||||||
) -> Result<Self::SerializeTupleVariant, E> {
|
) -> Result<Self::SerializeTupleVariant, E> {
|
||||||
Ok(SerializeTupleVariant {
|
Ok(SerializeTupleVariant {
|
||||||
name: name,
|
name,
|
||||||
variant_index: variant_index,
|
variant_index,
|
||||||
variant: variant,
|
variant,
|
||||||
fields: Vec::with_capacity(len),
|
fields: Vec::with_capacity(len),
|
||||||
error: PhantomData,
|
error: PhantomData,
|
||||||
})
|
})
|
||||||
@@ -747,7 +747,7 @@ mod content {
|
|||||||
len: usize,
|
len: usize,
|
||||||
) -> Result<Self::SerializeStruct, E> {
|
) -> Result<Self::SerializeStruct, E> {
|
||||||
Ok(SerializeStruct {
|
Ok(SerializeStruct {
|
||||||
name: name,
|
name,
|
||||||
fields: Vec::with_capacity(len),
|
fields: Vec::with_capacity(len),
|
||||||
error: PhantomData,
|
error: PhantomData,
|
||||||
})
|
})
|
||||||
@@ -761,9 +761,9 @@ mod content {
|
|||||||
len: usize,
|
len: usize,
|
||||||
) -> Result<Self::SerializeStructVariant, E> {
|
) -> Result<Self::SerializeStructVariant, E> {
|
||||||
Ok(SerializeStructVariant {
|
Ok(SerializeStructVariant {
|
||||||
name: name,
|
name,
|
||||||
variant_index: variant_index,
|
variant_index,
|
||||||
variant: variant,
|
variant,
|
||||||
fields: Vec::with_capacity(len),
|
fields: Vec::with_capacity(len),
|
||||||
error: PhantomData,
|
error: PhantomData,
|
||||||
})
|
})
|
||||||
@@ -1273,8 +1273,8 @@ where
|
|||||||
{
|
{
|
||||||
fn new(map: &'a mut M, name: &'static str) -> FlatMapSerializeStructVariantAsMapValue<'a, M> {
|
fn new(map: &'a mut M, name: &'static str) -> FlatMapSerializeStructVariantAsMapValue<'a, M> {
|
||||||
FlatMapSerializeStructVariantAsMapValue {
|
FlatMapSerializeStructVariantAsMapValue {
|
||||||
map: map,
|
map,
|
||||||
name: name,
|
name,
|
||||||
fields: Vec::new(),
|
fields: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -713,7 +713,7 @@ impl Serialize for net::IpAddr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
const DEC_DIGITS_LUT: &'static [u8] = b"\
|
const DEC_DIGITS_LUT: &[u8] = b"\
|
||||||
0001020304050607080910111213141516171819\
|
0001020304050607080910111213141516171819\
|
||||||
2021222324252627282930313233343536373839\
|
2021222324252627282930313233343536373839\
|
||||||
4041424344454647484950515253545556575859\
|
4041424344454647484950515253545556575859\
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
msrv = "1.31.0"
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.164" # remember to update html_root_url
|
version = "1.0.166" # 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>"]
|
||||||
categories = ["no-std"]
|
categories = ["no-std"]
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
@@ -24,7 +24,7 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = "2.0.3"
|
syn = "2.0.21"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde = { version = "1.0", path = "../serde" }
|
serde = { version = "1.0", path = "../serde" }
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ pub fn with_bound(
|
|||||||
};
|
};
|
||||||
match &cont.data {
|
match &cont.data {
|
||||||
Data::Enum(variants) => {
|
Data::Enum(variants) => {
|
||||||
for variant in variants.iter() {
|
for variant in variants {
|
||||||
let relevant_fields = variant
|
let relevant_fields = variant
|
||||||
.fields
|
.fields
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
+22
-14
@@ -445,14 +445,19 @@ fn deserialize_tuple(
|
|||||||
cattrs: &attr::Container,
|
cattrs: &attr::Container,
|
||||||
deserializer: Option<TokenStream>,
|
deserializer: Option<TokenStream>,
|
||||||
) -> Fragment {
|
) -> Fragment {
|
||||||
|
assert!(!cattrs.has_flatten());
|
||||||
|
|
||||||
|
let field_count = fields
|
||||||
|
.iter()
|
||||||
|
.filter(|field| !field.attrs.skip_deserializing())
|
||||||
|
.count();
|
||||||
|
|
||||||
let this_type = ¶ms.this_type;
|
let this_type = ¶ms.this_type;
|
||||||
let this_value = ¶ms.this_value;
|
let this_value = ¶ms.this_value;
|
||||||
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
|
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
|
||||||
split_with_de_lifetime(params);
|
split_with_de_lifetime(params);
|
||||||
let delife = params.borrowed.de_lifetime();
|
let delife = params.borrowed.de_lifetime();
|
||||||
|
|
||||||
assert!(!cattrs.has_flatten());
|
|
||||||
|
|
||||||
// If there are getters (implying private fields), construct the local type
|
// If there are getters (implying private fields), construct the local type
|
||||||
// and use an `Into` conversion to get the remote type. If there are no
|
// and use an `Into` conversion to get the remote type. If there are no
|
||||||
// getters then construct the target type directly.
|
// getters then construct the target type directly.
|
||||||
@@ -493,19 +498,18 @@ fn deserialize_tuple(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let dispatch = if let Some(deserializer) = deserializer {
|
let dispatch = if let Some(deserializer) = deserializer {
|
||||||
quote!(_serde::Deserializer::deserialize_tuple(#deserializer, #nfields, #visitor_expr))
|
quote!(_serde::Deserializer::deserialize_tuple(#deserializer, #field_count, #visitor_expr))
|
||||||
} else if is_enum {
|
} else if is_enum {
|
||||||
quote!(_serde::de::VariantAccess::tuple_variant(__variant, #nfields, #visitor_expr))
|
quote!(_serde::de::VariantAccess::tuple_variant(__variant, #field_count, #visitor_expr))
|
||||||
} else if nfields == 1 {
|
} else if nfields == 1 {
|
||||||
let type_name = cattrs.name().deserialize_name();
|
let type_name = cattrs.name().deserialize_name();
|
||||||
quote!(_serde::Deserializer::deserialize_newtype_struct(__deserializer, #type_name, #visitor_expr))
|
quote!(_serde::Deserializer::deserialize_newtype_struct(__deserializer, #type_name, #visitor_expr))
|
||||||
} else {
|
} else {
|
||||||
let type_name = cattrs.name().deserialize_name();
|
let type_name = cattrs.name().deserialize_name();
|
||||||
quote!(_serde::Deserializer::deserialize_tuple_struct(__deserializer, #type_name, #nfields, #visitor_expr))
|
quote!(_serde::Deserializer::deserialize_tuple_struct(__deserializer, #type_name, #field_count, #visitor_expr))
|
||||||
};
|
};
|
||||||
|
|
||||||
let all_skipped = fields.iter().all(|field| field.attrs.skip_deserializing());
|
let visitor_var = if field_count == 0 {
|
||||||
let visitor_var = if all_skipped {
|
|
||||||
quote!(_)
|
quote!(_)
|
||||||
} else {
|
} else {
|
||||||
quote!(mut __seq)
|
quote!(mut __seq)
|
||||||
@@ -548,13 +552,18 @@ fn deserialize_tuple_in_place(
|
|||||||
cattrs: &attr::Container,
|
cattrs: &attr::Container,
|
||||||
deserializer: Option<TokenStream>,
|
deserializer: Option<TokenStream>,
|
||||||
) -> Fragment {
|
) -> Fragment {
|
||||||
|
assert!(!cattrs.has_flatten());
|
||||||
|
|
||||||
|
let field_count = fields
|
||||||
|
.iter()
|
||||||
|
.filter(|field| !field.attrs.skip_deserializing())
|
||||||
|
.count();
|
||||||
|
|
||||||
let this_type = ¶ms.this_type;
|
let this_type = ¶ms.this_type;
|
||||||
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
|
let (de_impl_generics, de_ty_generics, ty_generics, where_clause) =
|
||||||
split_with_de_lifetime(params);
|
split_with_de_lifetime(params);
|
||||||
let delife = params.borrowed.de_lifetime();
|
let delife = params.borrowed.de_lifetime();
|
||||||
|
|
||||||
assert!(!cattrs.has_flatten());
|
|
||||||
|
|
||||||
let is_enum = variant_ident.is_some();
|
let is_enum = variant_ident.is_some();
|
||||||
let expecting = match variant_ident {
|
let expecting = match variant_ident {
|
||||||
Some(variant_ident) => format!("tuple variant {}::{}", params.type_name(), variant_ident),
|
Some(variant_ident) => format!("tuple variant {}::{}", params.type_name(), variant_ident),
|
||||||
@@ -580,19 +589,18 @@ fn deserialize_tuple_in_place(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let dispatch = if let Some(deserializer) = deserializer {
|
let dispatch = if let Some(deserializer) = deserializer {
|
||||||
quote!(_serde::Deserializer::deserialize_tuple(#deserializer, #nfields, #visitor_expr))
|
quote!(_serde::Deserializer::deserialize_tuple(#deserializer, #field_count, #visitor_expr))
|
||||||
} else if is_enum {
|
} else if is_enum {
|
||||||
quote!(_serde::de::VariantAccess::tuple_variant(__variant, #nfields, #visitor_expr))
|
quote!(_serde::de::VariantAccess::tuple_variant(__variant, #field_count, #visitor_expr))
|
||||||
} else if nfields == 1 {
|
} else if nfields == 1 {
|
||||||
let type_name = cattrs.name().deserialize_name();
|
let type_name = cattrs.name().deserialize_name();
|
||||||
quote!(_serde::Deserializer::deserialize_newtype_struct(__deserializer, #type_name, #visitor_expr))
|
quote!(_serde::Deserializer::deserialize_newtype_struct(__deserializer, #type_name, #visitor_expr))
|
||||||
} else {
|
} else {
|
||||||
let type_name = cattrs.name().deserialize_name();
|
let type_name = cattrs.name().deserialize_name();
|
||||||
quote!(_serde::Deserializer::deserialize_tuple_struct(__deserializer, #type_name, #nfields, #visitor_expr))
|
quote!(_serde::Deserializer::deserialize_tuple_struct(__deserializer, #type_name, #field_count, #visitor_expr))
|
||||||
};
|
};
|
||||||
|
|
||||||
let all_skipped = fields.iter().all(|field| field.attrs.skip_deserializing());
|
let visitor_var = if field_count == 0 {
|
||||||
let visitor_var = if all_skipped {
|
|
||||||
quote!(_)
|
quote!(_)
|
||||||
} else {
|
} else {
|
||||||
quote!(mut __seq)
|
quote!(mut __seq)
|
||||||
|
|||||||
@@ -110,9 +110,7 @@ fn check_flatten_field(cx: &Ctxt, style: Style, field: &Field) {
|
|||||||
fn check_identifier(cx: &Ctxt, cont: &Container) {
|
fn check_identifier(cx: &Ctxt, cont: &Container) {
|
||||||
let variants = match &cont.data {
|
let variants = match &cont.data {
|
||||||
Data::Enum(variants) => variants,
|
Data::Enum(variants) => variants,
|
||||||
Data::Struct(_, _) => {
|
Data::Struct(_, _) => return,
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i, variant) in variants.iter().enumerate() {
|
for (i, variant) in variants.iter().enumerate() {
|
||||||
@@ -194,12 +192,10 @@ fn check_identifier(cx: &Ctxt, cont: &Container) {
|
|||||||
fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
|
fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) {
|
||||||
let variants = match &cont.data {
|
let variants = match &cont.data {
|
||||||
Data::Enum(variants) => variants,
|
Data::Enum(variants) => variants,
|
||||||
Data::Struct(_, _) => {
|
Data::Struct(_, _) => return,
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for variant in variants.iter() {
|
for variant in variants {
|
||||||
if variant.attrs.serialize_with().is_some() {
|
if variant.attrs.serialize_with().is_some() {
|
||||||
if variant.attrs.skip_serializing() {
|
if variant.attrs.skip_serializing() {
|
||||||
cx.error_spanned_by(
|
cx.error_spanned_by(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
//!
|
//!
|
||||||
//! [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.164")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.166")]
|
||||||
#![allow(unknown_lints, bare_trait_objects)]
|
#![allow(unknown_lints, bare_trait_objects)]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
msrv = "1.31.0"
|
|
||||||
@@ -17,7 +17,7 @@ path = "lib.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "2.0", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] }
|
syn = { version = "2.0.21", 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 +0,0 @@
|
|||||||
msrv = "1.13.0"
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.164" # remember to update html_root_url
|
version = "1.0.166" # 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>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
categories = ["development-tools::testing"]
|
categories = ["development-tools::testing"]
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.164")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.166")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
|
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp, needless_doctest_main))]
|
||||||
|
|||||||
@@ -1533,7 +1533,7 @@ fn test_invalid_length_enum() {
|
|||||||
Token::TupleVariant {
|
Token::TupleVariant {
|
||||||
name: "InvalidLengthEnum",
|
name: "InvalidLengthEnum",
|
||||||
variant: "B",
|
variant: "B",
|
||||||
len: 3,
|
len: 2,
|
||||||
},
|
},
|
||||||
Token::I32(1),
|
Token::I32(1),
|
||||||
Token::TupleVariantEnd,
|
Token::TupleVariantEnd,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
use std::iter;
|
||||||
use std::net;
|
use std::net;
|
||||||
use std::num::{
|
use std::num::{
|
||||||
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
|
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
|
||||||
@@ -199,7 +200,7 @@ fn assert_de_tokens_ignore(ignorable_tokens: &[Token]) {
|
|||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(ignorable_tokens.iter().copied())
|
.chain(ignorable_tokens.iter().copied())
|
||||||
.chain(vec![Token::MapEnd].into_iter())
|
.chain(iter::once(Token::MapEnd))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let expected = IgnoreBase { a: 1 };
|
let expected = IgnoreBase { a: 1 };
|
||||||
|
|||||||
Reference in New Issue
Block a user