mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-25 02:21:05 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c5f20c148 | |||
| aa2bbb4704 | |||
| 16d1265e17 | |||
| f09320b293 | |||
| 3b4803115b | |||
| fa5f0f4541 | |||
| 4b7f55bd42 | |||
| 593bcb087d | |||
| f58000cb41 | |||
| 01b86d5ce4 | |||
| c80f9238d7 | |||
| 62850bf832 | |||
| 9f114548f4 | |||
| 8890061f82 | |||
| 2c05518810 | |||
| 4aeb0df88f |
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
name: Anything else!
|
||||||
|
about: Whatever is on your mind
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
+3
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.55" # remember to update html_root_url
|
version = "1.0.58" # 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"
|
||||||
@@ -10,7 +10,8 @@ documentation = "https://docs.serde.rs/serde/"
|
|||||||
keywords = ["serde", "serialization", "no_std"]
|
keywords = ["serde", "serialization", "no_std"]
|
||||||
categories = ["encoding"]
|
categories = ["encoding"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
include = ["Cargo.toml", "build.rs", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
travis-ci = { repository = "serde-rs/serde" }
|
travis-ci = { repository = "serde-rs/serde" }
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::process::Command;
|
||||||
|
use std::str::{self, FromStr};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let rustc = match env::var_os("RUSTC") {
|
||||||
|
Some(rustc) => rustc,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
let output = match Command::new(rustc).arg("--version").output() {
|
||||||
|
Ok(output) => output,
|
||||||
|
Err(_) => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
let version = match str::from_utf8(&output.stdout) {
|
||||||
|
Ok(version) => version,
|
||||||
|
Err(_) => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut pieces = version.split('.');
|
||||||
|
if pieces.next() != Some("rustc 1") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let next = match pieces.next() {
|
||||||
|
Some(next) => next,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
let minor = match u32::from_str(next) {
|
||||||
|
Ok(minor) => minor,
|
||||||
|
Err(_) => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 128-bit integers stabilized in Rust 1.26:
|
||||||
|
// https://blog.rust-lang.org/2018/05/10/Rust-1.26.html
|
||||||
|
if minor >= 26 {
|
||||||
|
println!("cargo:rustc-cfg=integer128");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,12 +39,10 @@ macro_rules! uint_to {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait FromPrimitive: Sized {
|
pub trait FromPrimitive: Sized {
|
||||||
fn from_isize(n: isize) -> Option<Self>;
|
|
||||||
fn from_i8(n: i8) -> Option<Self>;
|
fn from_i8(n: i8) -> Option<Self>;
|
||||||
fn from_i16(n: i16) -> Option<Self>;
|
fn from_i16(n: i16) -> Option<Self>;
|
||||||
fn from_i32(n: i32) -> Option<Self>;
|
fn from_i32(n: i32) -> Option<Self>;
|
||||||
fn from_i64(n: i64) -> Option<Self>;
|
fn from_i64(n: i64) -> Option<Self>;
|
||||||
fn from_usize(n: usize) -> Option<Self>;
|
|
||||||
fn from_u8(n: u8) -> Option<Self>;
|
fn from_u8(n: u8) -> Option<Self>;
|
||||||
fn from_u16(n: u16) -> Option<Self>;
|
fn from_u16(n: u16) -> Option<Self>;
|
||||||
fn from_u32(n: u32) -> Option<Self>;
|
fn from_u32(n: u32) -> Option<Self>;
|
||||||
@@ -54,10 +52,6 @@ pub trait FromPrimitive: Sized {
|
|||||||
macro_rules! impl_from_primitive_for_int {
|
macro_rules! impl_from_primitive_for_int {
|
||||||
($t:ident) => {
|
($t:ident) => {
|
||||||
impl FromPrimitive for $t {
|
impl FromPrimitive for $t {
|
||||||
#[inline]
|
|
||||||
fn from_isize(n: isize) -> Option<Self> {
|
|
||||||
int_to_int!($t, n)
|
|
||||||
}
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_i8(n: i8) -> Option<Self> {
|
fn from_i8(n: i8) -> Option<Self> {
|
||||||
int_to_int!($t, n)
|
int_to_int!($t, n)
|
||||||
@@ -75,10 +69,6 @@ macro_rules! impl_from_primitive_for_int {
|
|||||||
int_to_int!($t, n)
|
int_to_int!($t, n)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_usize(n: usize) -> Option<Self> {
|
|
||||||
uint_to!($t, n)
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
fn from_u8(n: u8) -> Option<Self> {
|
fn from_u8(n: u8) -> Option<Self> {
|
||||||
uint_to!($t, n)
|
uint_to!($t, n)
|
||||||
}
|
}
|
||||||
@@ -101,10 +91,6 @@ macro_rules! impl_from_primitive_for_int {
|
|||||||
macro_rules! impl_from_primitive_for_uint {
|
macro_rules! impl_from_primitive_for_uint {
|
||||||
($t:ident) => {
|
($t:ident) => {
|
||||||
impl FromPrimitive for $t {
|
impl FromPrimitive for $t {
|
||||||
#[inline]
|
|
||||||
fn from_isize(n: isize) -> Option<Self> {
|
|
||||||
int_to_uint!($t, n)
|
|
||||||
}
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_i8(n: i8) -> Option<Self> {
|
fn from_i8(n: i8) -> Option<Self> {
|
||||||
int_to_uint!($t, n)
|
int_to_uint!($t, n)
|
||||||
@@ -122,10 +108,6 @@ macro_rules! impl_from_primitive_for_uint {
|
|||||||
int_to_uint!($t, n)
|
int_to_uint!($t, n)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_usize(n: usize) -> Option<Self> {
|
|
||||||
uint_to!($t, n)
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
fn from_u8(n: u8) -> Option<Self> {
|
fn from_u8(n: u8) -> Option<Self> {
|
||||||
uint_to!($t, n)
|
uint_to!($t, n)
|
||||||
}
|
}
|
||||||
@@ -148,10 +130,6 @@ macro_rules! impl_from_primitive_for_uint {
|
|||||||
macro_rules! impl_from_primitive_for_float {
|
macro_rules! impl_from_primitive_for_float {
|
||||||
($t:ident) => {
|
($t:ident) => {
|
||||||
impl FromPrimitive for $t {
|
impl FromPrimitive for $t {
|
||||||
#[inline]
|
|
||||||
fn from_isize(n: isize) -> Option<Self> {
|
|
||||||
Some(n as Self)
|
|
||||||
}
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_i8(n: i8) -> Option<Self> {
|
fn from_i8(n: i8) -> Option<Self> {
|
||||||
Some(n as Self)
|
Some(n as Self)
|
||||||
@@ -169,10 +147,6 @@ macro_rules! impl_from_primitive_for_float {
|
|||||||
Some(n as Self)
|
Some(n as Self)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_usize(n: usize) -> Option<Self> {
|
|
||||||
Some(n as Self)
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
fn from_u8(n: u8) -> Option<Self> {
|
fn from_u8(n: u8) -> Option<Self> {
|
||||||
Some(n as Self)
|
Some(n as Self)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2005,24 +2005,6 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
impl<'de, T> Deserialize<'de> for NonZero<T>
|
|
||||||
where
|
|
||||||
T: Deserialize<'de> + Zeroable,
|
|
||||||
{
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let value = try!(Deserialize::deserialize(deserializer));
|
|
||||||
match NonZero::new(value) {
|
|
||||||
Some(nonzero) => Ok(nonzero),
|
|
||||||
None => Err(Error::custom("expected a non-zero value")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! nonzero_integers {
|
macro_rules! nonzero_integers {
|
||||||
( $( $T: ty, )+ ) => {
|
( $( $T: ty, )+ ) => {
|
||||||
$(
|
$(
|
||||||
|
|||||||
@@ -84,7 +84,6 @@
|
|||||||
//! - LinkedList\<T\>
|
//! - LinkedList\<T\>
|
||||||
//! - VecDeque\<T\>
|
//! - VecDeque\<T\>
|
||||||
//! - Vec\<T\>
|
//! - Vec\<T\>
|
||||||
//! - EnumSet\<T\> (unstable)
|
|
||||||
//! - **Zero-copy types**:
|
//! - **Zero-copy types**:
|
||||||
//! - &str
|
//! - &str
|
||||||
//! - &[u8]
|
//! - &[u8]
|
||||||
@@ -98,7 +97,6 @@
|
|||||||
//! - Path
|
//! - Path
|
||||||
//! - PathBuf
|
//! - PathBuf
|
||||||
//! - Range\<T\>
|
//! - Range\<T\>
|
||||||
//! - NonZero\<T\> (unstable, deprecated)
|
|
||||||
//! - num::NonZero* (unstable)
|
//! - num::NonZero* (unstable)
|
||||||
//! - **Net types**:
|
//! - **Net types**:
|
||||||
//! - IpAddr
|
//! - IpAddr
|
||||||
|
|||||||
+2
-6
@@ -79,14 +79,14 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Serde types in rustdoc of other crates get linked to here.
|
// Serde types in rustdoc of other crates get linked to here.
|
||||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.55")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.58")]
|
||||||
// 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(nonzero, specialization))]
|
#![cfg_attr(feature = "unstable", feature(specialization))]
|
||||||
#![cfg_attr(feature = "alloc", feature(alloc))]
|
#![cfg_attr(feature = "alloc", feature(alloc))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Whitelisted clippy lints
|
// Whitelisted clippy lints
|
||||||
@@ -213,10 +213,6 @@ mod lib {
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
pub use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
pub use core::nonzero::{NonZero, Zeroable};
|
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
pub use core::num::{NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize};
|
pub use core::num::{NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,20 +408,6 @@ where
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
impl<T> Serialize for NonZero<T>
|
|
||||||
where
|
|
||||||
T: Serialize + Zeroable + Clone,
|
|
||||||
{
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
self.clone().get().serialize(serializer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! nonzero_integers {
|
macro_rules! nonzero_integers {
|
||||||
( $( $T: ident, )+ ) => {
|
( $( $T: ident, )+ ) => {
|
||||||
$(
|
$(
|
||||||
|
|||||||
@@ -81,7 +81,6 @@
|
|||||||
//! - LinkedList\<T\>
|
//! - LinkedList\<T\>
|
||||||
//! - VecDeque\<T\>
|
//! - VecDeque\<T\>
|
||||||
//! - Vec\<T\>
|
//! - Vec\<T\>
|
||||||
//! - EnumSet\<T\> (unstable)
|
|
||||||
//! - **FFI types**:
|
//! - **FFI types**:
|
||||||
//! - CStr
|
//! - CStr
|
||||||
//! - CString
|
//! - CString
|
||||||
@@ -93,7 +92,6 @@
|
|||||||
//! - Path
|
//! - Path
|
||||||
//! - PathBuf
|
//! - PathBuf
|
||||||
//! - Range\<T\>
|
//! - Range\<T\>
|
||||||
//! - NonZero\<T\> (unstable, deprecated)
|
|
||||||
//! - num::NonZero* (unstable)
|
//! - num::NonZero* (unstable)
|
||||||
//! - **Net types**:
|
//! - **Net types**:
|
||||||
//! - IpAddr
|
//! - IpAddr
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.55" # remember to update html_root_url
|
version = "1.0.58" # 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)]"
|
||||||
|
|||||||
@@ -1802,10 +1802,8 @@ fn deserialize_untagged_newtype_variant(
|
|||||||
}
|
}
|
||||||
Some(path) => {
|
Some(path) => {
|
||||||
quote_block! {
|
quote_block! {
|
||||||
let __value: #field_ty = _serde::export::Result::map(
|
let __value: _serde::export::Result<#field_ty, _> = #path(#deserializer);
|
||||||
#path(#deserializer),
|
_serde::export::Result::map(__value, #this::#variant_ident)
|
||||||
#this::#variant_ident);
|
|
||||||
__value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,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.55")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.58")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Whitelisted clippy lints
|
// Whitelisted clippy lints
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.55" # remember to update html_root_url
|
version = "1.0.58" # 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"
|
||||||
|
|||||||
@@ -161,7 +161,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.55")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.58")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Whitelisted clippy lints
|
// Whitelisted clippy lints
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
|
#![cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
|
||||||
|
|||||||
@@ -643,6 +643,16 @@ fn test_gen() {
|
|||||||
struct ImpliciltyBorrowedOption<'a> {
|
struct ImpliciltyBorrowedOption<'a> {
|
||||||
option: std::option::Option<&'a str>,
|
option: std::option::Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
enum UntaggedNewtypeVariantWith {
|
||||||
|
Newtype(
|
||||||
|
#[serde(serialize_with = "ser_x")]
|
||||||
|
#[serde(deserialize_with = "de_x")]
|
||||||
|
X,
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ else
|
|||||||
channel build
|
channel build
|
||||||
cd "$DIR/test_suite"
|
cd "$DIR/test_suite"
|
||||||
channel test --features unstable
|
channel test --features unstable
|
||||||
channel build --tests --features proc-macro2/nightly
|
# Broken while syn and quote update to the new proc-macro API
|
||||||
|
#channel build --tests --features proc-macro2/nightly
|
||||||
if [ -z "${APPVEYOR}" ]; then
|
if [ -z "${APPVEYOR}" ]; then
|
||||||
cd "$DIR/test_suite/no_std"
|
cd "$DIR/test_suite/no_std"
|
||||||
channel build
|
channel build
|
||||||
|
|||||||
Reference in New Issue
Block a user