mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 05:07:56 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ae79451b7a | |||
| 1a2b3815ef | |||
| 1d6ecf3c2c |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "0.9.14"
|
version = "0.9.15"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
|
|||||||
+15
-10
@@ -20,10 +20,14 @@ use core::fmt;
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use core::hash::{Hash, BuildHasher};
|
use core::hash::{Hash, BuildHasher};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
#[cfg(all(feature="unstable"))]
|
||||||
|
use core::mem;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::net;
|
use std::net;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::path;
|
use std::path;
|
||||||
|
#[cfg(all(feature="unstable"))]
|
||||||
|
use core::slice;
|
||||||
use core::str;
|
use core::str;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::ffi::{CString, OsString};
|
use std::ffi::{CString, OsString};
|
||||||
@@ -57,10 +61,6 @@ use std;
|
|||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
use core::nonzero::{NonZero, Zeroable};
|
use core::nonzero::{NonZero, Zeroable};
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
|
||||||
#[allow(deprecated)] // required for impl Deserialize for NonZero<T>
|
|
||||||
use core::num::Zero;
|
|
||||||
|
|
||||||
use de::{Deserialize, Deserializer, EnumVisitor, Error, MapVisitor, SeqVisitor, Unexpected,
|
use de::{Deserialize, Deserializer, EnumVisitor, Error, MapVisitor, SeqVisitor, Unexpected,
|
||||||
VariantVisitor, Visitor};
|
VariantVisitor, Visitor};
|
||||||
use de::from_primitive::FromPrimitive;
|
use de::from_primitive::FromPrimitive;
|
||||||
@@ -1409,18 +1409,23 @@ impl<Idx: Deserialize> Deserialize for std::ops::Range<Idx> {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[cfg(feature = "unstable")]
|
#[cfg(feature = "unstable")]
|
||||||
#[allow(deprecated)] // num::Zero is deprecated but there is no replacement
|
|
||||||
impl<T> Deserialize for NonZero<T>
|
impl<T> Deserialize for NonZero<T>
|
||||||
where T: Deserialize + PartialEq + Zeroable + Zero
|
where T: Deserialize + Zeroable
|
||||||
{
|
{
|
||||||
fn deserialize<D>(deserializer: D) -> Result<NonZero<T>, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<NonZero<T>, D::Error>
|
||||||
where D: Deserializer
|
where D: Deserializer
|
||||||
{
|
{
|
||||||
let value = try!(Deserialize::deserialize(deserializer));
|
let value = try!(Deserialize::deserialize(deserializer));
|
||||||
if value == Zero::zero() {
|
unsafe {
|
||||||
return Err(Error::custom("expected a non-zero value"));
|
let ptr = &value as *const T as *const u8;
|
||||||
}
|
if slice::from_raw_parts(ptr, mem::size_of::<T>()).iter().all(|&b| b == 0) {
|
||||||
unsafe { Ok(NonZero::new(value)) }
|
return Err(Error::custom("expected a non-zero value"));
|
||||||
|
}
|
||||||
|
// Waiting for a safe way to construct NonZero<T>:
|
||||||
|
// https://github.com/rust-lang/rust/issues/27730#issuecomment-269726075
|
||||||
|
Ok(NonZero::new(value))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
#![doc(html_root_url="https://docs.serde.rs")]
|
#![doc(html_root_url="https://docs.serde.rs")]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![cfg_attr(feature = "unstable", feature(nonzero, specialization, zero_one, into_boxed_c_str))]
|
#![cfg_attr(feature = "unstable", feature(nonzero, specialization, into_boxed_c_str))]
|
||||||
#![cfg_attr(feature = "alloc", feature(alloc))]
|
#![cfg_attr(feature = "alloc", feature(alloc))]
|
||||||
#![cfg_attr(feature = "collections", feature(collections))]
|
#![cfg_attr(feature = "collections", feature(collections))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(linkedlist, type_complexity, doc_markdown))]
|
#![cfg_attr(feature = "cargo-clippy", allow(linkedlist, type_complexity, doc_markdown))]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "0.9.14"
|
version = "0.9.15"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@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)]"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "0.9.14"
|
version = "0.9.15"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@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"
|
||||||
|
|||||||
Reference in New Issue
Block a user