mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-27 14:37:55 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f331cc257 | |||
| ef16c815f6 | |||
| c45a809d5c | |||
| f7d06cae4c | |||
| 31fe82a215 | |||
| ef6ed1d1be | |||
| 9d1251548b | |||
| c20730ee39 | |||
| afd51ef0f4 | |||
| 3167f98689 |
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
+2
-2
@@ -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.111" # remember to update html_root_url and serde_derive dependency
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
@@ -14,7 +14,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "crates-io.md", "README.md",
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.110", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "=1.0.111", 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" }
|
||||||
|
|||||||
+6
-1
@@ -53,6 +53,9 @@
|
|||||||
//! *(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.
|
||||||
//!
|
//!
|
||||||
//! [JSON]: https://github.com/serde-rs/json
|
//! [JSON]: https://github.com/serde-rs/json
|
||||||
//! [Bincode]: https://github.com/TyOverby/bincode
|
//! [Bincode]: https://github.com/TyOverby/bincode
|
||||||
@@ -71,11 +74,13 @@
|
|||||||
//! [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
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// 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.111")]
|
||||||
// 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
|
||||||
|
|||||||
@@ -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",
|
||||||
)),
|
)),
|
||||||
|
|||||||
@@ -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.111" # 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)]"
|
||||||
|
|||||||
@@ -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,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;
|
||||||
@@ -1737,7 +1737,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 +1764,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 +1811,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 +1822,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,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.110")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.111")]
|
||||||
#![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
|
||||||
|
|||||||
@@ -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.111" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.110")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.111")]
|
||||||
#![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
|
||||||
|
|||||||
@@ -708,6 +708,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user