mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 05:07:56 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d7aad1e7b | |||
| e792874369 | |||
| 1669c69714 | |||
| 4d5e450054 | |||
| 26b22e647d | |||
| cda1fc46b0 |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.4" # remember to update html_root_url
|
version = "1.0.6" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,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.4")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.6")]
|
||||||
|
|
||||||
// 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)]
|
||||||
|
|||||||
@@ -1082,7 +1082,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
(variant, Some(value))
|
(variant, Some(value))
|
||||||
}
|
}
|
||||||
Content::String(variant) => (Content::String(variant), None),
|
s @ Content::String(_) | s @ Content::Str(_) => (s, None),
|
||||||
other => {
|
other => {
|
||||||
return Err(de::Error::invalid_type(other.unexpected(), &"string or map"),);
|
return Err(de::Error::invalid_type(other.unexpected(), &"string or map"),);
|
||||||
}
|
}
|
||||||
@@ -1476,7 +1476,7 @@ mod content {
|
|||||||
}
|
}
|
||||||
(variant, Some(value))
|
(variant, Some(value))
|
||||||
}
|
}
|
||||||
ref s @ Content::String(_) => (s, None),
|
ref s @ Content::String(_) | ref s @ Content::Str(_) => (s, None),
|
||||||
ref other => {
|
ref other => {
|
||||||
return Err(de::Error::invalid_type(other.unexpected(), &"string or map"),);
|
return Err(de::Error::invalid_type(other.unexpected(), &"string or map"),);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.4" # remember to update html_root_url
|
version = "1.0.6" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
|
|||||||
@@ -16,7 +16,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.4")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.6")]
|
||||||
|
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
|
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))]
|
#![cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))]
|
||||||
|
|||||||
@@ -719,6 +719,12 @@ impl Field {
|
|||||||
skip_deserializing.set_true();
|
skip_deserializing.set_true();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse `#[serde(skip)]`
|
||||||
|
MetaItem(Word(ref name)) if name == "skip" => {
|
||||||
|
skip_serializing.set_true();
|
||||||
|
skip_deserializing.set_true();
|
||||||
|
},
|
||||||
|
|
||||||
// Parse `#[serde(skip_serializing_if = "...")]`
|
// Parse `#[serde(skip_serializing_if = "...")]`
|
||||||
MetaItem(NameValue(ref name, ref lit)) if name == "skip_serializing_if" => {
|
MetaItem(NameValue(ref name, ref lit)) if name == "skip_serializing_if" => {
|
||||||
if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) {
|
if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.4" # remember to update html_root_url
|
version = "1.0.6" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||||
|
|||||||
@@ -155,7 +155,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.4")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.6")]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
|||||||
@@ -580,6 +580,41 @@ fn test_skip_serializing_struct() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
struct SkipStruct<B>
|
||||||
|
{
|
||||||
|
a: i8,
|
||||||
|
#[serde(skip)]
|
||||||
|
b: B,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_skip_struct() {
|
||||||
|
assert_ser_tokens(
|
||||||
|
&SkipStruct { a: 1, b: 2 },
|
||||||
|
&[
|
||||||
|
Token::Struct { name: "SkipStruct", len: 1 },
|
||||||
|
|
||||||
|
Token::Str("a"),
|
||||||
|
Token::I8(1),
|
||||||
|
|
||||||
|
Token::StructEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_de_tokens(
|
||||||
|
&SkipStruct { a: 1, b: 0 },
|
||||||
|
&[
|
||||||
|
Token::Struct { name: "SkipStruct", len: 1 },
|
||||||
|
|
||||||
|
Token::Str("a"),
|
||||||
|
Token::I8(1),
|
||||||
|
|
||||||
|
Token::StructEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize)]
|
#[derive(Debug, PartialEq, Serialize)]
|
||||||
enum SkipSerializingEnum<'a, B, C>
|
enum SkipSerializingEnum<'a, B, C>
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -695,6 +695,35 @@ fn test_internally_tagged_enum() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_internally_tagged_struct_variant_containing_unit_variant() {
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub enum Level {
|
||||||
|
Info,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "action")]
|
||||||
|
pub enum Message {
|
||||||
|
Log { level: Level },
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_de_tokens(
|
||||||
|
&Message::Log { level: Level::Info },
|
||||||
|
&[
|
||||||
|
Token::Struct { name: "Message", len: 2 },
|
||||||
|
|
||||||
|
Token::Str("action"),
|
||||||
|
Token::Str("Log"),
|
||||||
|
|
||||||
|
Token::Str("level"),
|
||||||
|
Token::BorrowedStr("Info"),
|
||||||
|
|
||||||
|
Token::StructEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_internally_tagged_borrow() {
|
fn test_internally_tagged_borrow() {
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
|||||||
Reference in New Issue
Block a user