mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 16:28:02 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0bdb88b70 | |||
| 5d546231a1 | |||
| 0a75fdd839 | |||
| c03215db8d | |||
| 877abfe00e | |||
| a155b33847 | |||
| 10dc33548a | |||
| ee2259c972 | |||
| 0084743f82 | |||
| 679af0fb4b | |||
| d99c876120 | |||
| 7ce49dc38b |
+39
-13
@@ -97,7 +97,9 @@
|
||||
// Serde types in rustdoc of other crates get linked to here.
|
||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.228")]
|
||||
// Support using Serde without the standard library!
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// Also force no_std on target_os = "none" (wasm32v1-none) even if std feature is enabled
|
||||
// This handles Cargo feature unification where std gets enabled for no_std targets
|
||||
#![cfg_attr(any(not(feature = "std"), target_os = "none"), no_std)]
|
||||
// Show which crate feature enables conditionally compiled APIs in documentation.
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, rustdoc_internals))]
|
||||
#![cfg_attr(docsrs, allow(internal_features))]
|
||||
@@ -168,6 +170,10 @@
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
|
||||
// Explicitly import core crate for no_std targets (especially wasm32v1-none)
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
extern crate core;
|
||||
|
||||
// Rustdoc has a lot of shortcomings related to cross-crate re-exports that make
|
||||
// the rendered documentation of serde_core traits in serde more challenging to
|
||||
// understand than the equivalent documentation of the same items in serde_core.
|
||||
@@ -190,14 +196,34 @@ macro_rules! crate_root {
|
||||
/// A facade around all the types we need from the `std`, `core`, and `alloc`
|
||||
/// crates. This avoids elaborate import wrangling having to happen in every
|
||||
/// module.
|
||||
///
|
||||
/// NOTE: On targets where std is not available (target_os = "none", e.g. wasm32v1-none),
|
||||
/// we always use core/alloc even if the "std" feature is enabled due to Cargo feature
|
||||
/// unification.
|
||||
mod lib {
|
||||
mod core {
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use core::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::*;
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::*;
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::*;
|
||||
}
|
||||
|
||||
// Re-export the full prelude for wasm32v1-none and other no_std targets
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::prelude::rust_2021::*;
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::prelude::rust_2021::*;
|
||||
|
||||
// Prelude items that may not be re-exported by glob import
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::option::Option::{self, None, Some};
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::result::Result::{self, Err, Ok};
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::option::Option::{self, None, Some};
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::result::Result::{self, Err, Ok};
|
||||
|
||||
pub use self::core::{f32, f64};
|
||||
pub use self::core::{ptr, str};
|
||||
|
||||
@@ -212,24 +238,24 @@ macro_rules! crate_root {
|
||||
pub use self::core::option;
|
||||
pub use self::core::result;
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::borrow::{Cow, ToOwned};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::borrow::{Cow, ToOwned};
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::string::{String, ToString};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::string::{String, ToString};
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::vec::Vec;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::vec::Vec;
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::boxed::Box;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::boxed::Box;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none and other no_std targets
|
||||
#[allow(unused_imports)]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
#[allow(unused_imports)]
|
||||
use ::core::write;
|
||||
|
||||
use crate::de::value::{BorrowedBytesDeserializer, BytesDeserializer};
|
||||
use crate::de::{
|
||||
Deserialize, DeserializeSeed, Deserializer, EnumAccess, Error, IntoDeserializer, VariantAccess,
|
||||
@@ -212,6 +218,12 @@ mod content {
|
||||
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none and other no_std targets
|
||||
#[allow(unused_imports)]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
#[allow(unused_imports)]
|
||||
use ::core::write;
|
||||
|
||||
use crate::de::{
|
||||
self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
|
||||
MapAccess, SeqAccess, Unexpected, Visitor,
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none and other no_std targets
|
||||
#[allow(unused_imports)]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
#[allow(unused_imports)]
|
||||
use ::core::write;
|
||||
|
||||
use crate::ser::{self, Impossible, Serialize, SerializeMap, SerializeStruct, Serializer};
|
||||
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
@@ -339,6 +345,10 @@ where
|
||||
mod content {
|
||||
use crate::lib::*;
|
||||
|
||||
// Explicit prelude import for wasm32v1-none and other no_std targets
|
||||
#[allow(unused_imports)]
|
||||
use ::core::prelude::rust_2021::*;
|
||||
|
||||
use crate::ser::{self, Serialize, Serializer};
|
||||
|
||||
pub struct SerializeTupleVariantAsMapValue<M> {
|
||||
|
||||
@@ -3,14 +3,37 @@ macro_rules! crate_root {
|
||||
/// A facade around all the types we need from the `std`, `core`, and `alloc`
|
||||
/// crates. This avoids elaborate import wrangling having to happen in every
|
||||
/// module.
|
||||
///
|
||||
/// NOTE: On targets where std is not available (target_os = "none", e.g. wasm32v1-none),
|
||||
/// we always use core/alloc even if the "std" feature is enabled due to Cargo feature
|
||||
/// unification. This is handled by checking `target_os = "none"` in all cfg conditions.
|
||||
mod lib {
|
||||
mod core {
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub use core::*;
|
||||
#[cfg(feature = "std")]
|
||||
pub use std::*;
|
||||
// On wasm32v1-none (target_os = "none"), always use ::core even if std feature is enabled
|
||||
// This handles Cargo feature unification where std gets enabled for no_std targets
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::*;
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::*;
|
||||
}
|
||||
|
||||
// Re-export the full prelude for wasm32v1-none and other no_std targets
|
||||
// On target_os = "none", always use ::core::prelude even with std feature
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::prelude::rust_2021::*;
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::prelude::rust_2021::*;
|
||||
|
||||
// Prelude items that may not be re-exported by glob import
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::option::Option::{self, None, Some};
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
pub use ::core::result::Result::{self, Err, Ok};
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::option::Option::{self, None, Some};
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use ::std::result::Result::{self, Err, Ok};
|
||||
|
||||
pub use self::core::{f32, f64};
|
||||
pub use self::core::{iter, num, str};
|
||||
|
||||
@@ -20,99 +43,110 @@ macro_rules! crate_root {
|
||||
pub use self::core::cell::{Cell, RefCell};
|
||||
pub use self::core::cmp::Reverse;
|
||||
pub use self::core::fmt::{self, Debug, Display, Write as FmtWrite};
|
||||
pub use self::core::marker::PhantomData;
|
||||
pub use self::core::marker::{PhantomData, Sized};
|
||||
pub use self::core::clone::Clone;
|
||||
pub use self::core::marker::{Copy, Send, Sync, Unpin};
|
||||
pub use self::core::default::Default;
|
||||
pub use self::core::cmp::{Eq, Ord, PartialEq, PartialOrd};
|
||||
pub use self::core::convert::{AsMut, AsRef, From, Into};
|
||||
pub use self::core::iter::{
|
||||
DoubleEndedIterator, ExactSizeIterator, Extend, IntoIterator, Iterator,
|
||||
};
|
||||
pub use self::core::ops::{Drop, Fn, FnMut, FnOnce};
|
||||
pub use self::core::num::Wrapping;
|
||||
pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo};
|
||||
pub use self::core::result;
|
||||
pub use self::core::time::Duration;
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
// For alloc types: use alloc when std is not available OR on target_os = "none"
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::borrow::{Cow, ToOwned};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::borrow::{Cow, ToOwned};
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::string::{String, ToString};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::string::{String, ToString};
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::vec::Vec;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::vec::Vec;
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::boxed::Box;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::boxed::Box;
|
||||
|
||||
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "rc", feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::rc::{Rc, Weak as RcWeak};
|
||||
#[cfg(all(feature = "rc", feature = "std"))]
|
||||
#[cfg(all(feature = "rc", feature = "std", not(target_os = "none")))]
|
||||
pub use std::rc::{Rc, Weak as RcWeak};
|
||||
|
||||
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "rc", feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::sync::{Arc, Weak as ArcWeak};
|
||||
#[cfg(all(feature = "rc", feature = "std"))]
|
||||
#[cfg(all(feature = "rc", feature = "std", not(target_os = "none")))]
|
||||
pub use std::sync::{Arc, Weak as ArcWeak};
|
||||
|
||||
#[cfg(all(feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque};
|
||||
|
||||
#[cfg(all(not(no_core_cstr), not(feature = "std")))]
|
||||
#[cfg(all(not(no_core_cstr), any(not(feature = "std"), target_os = "none")))]
|
||||
pub use self::core::ffi::CStr;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::ffi::CStr;
|
||||
|
||||
#[cfg(all(not(no_core_cstr), feature = "alloc", not(feature = "std")))]
|
||||
#[cfg(all(not(no_core_cstr), feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
pub use alloc::ffi::CString;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::ffi::CString;
|
||||
|
||||
#[cfg(all(not(no_core_net), not(feature = "std")))]
|
||||
#[cfg(all(not(no_core_net), any(not(feature = "std"), target_os = "none")))]
|
||||
pub use self::core::net;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::net;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
// std-only types - not available on target_os = "none"
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::error;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::collections::{HashMap, HashSet};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::ffi::{OsStr, OsString};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::hash::{BuildHasher, Hash};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::io::Write;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::path::{Path, PathBuf};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::sync::{Mutex, RwLock};
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
pub use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), no_target_has_atomic, not(no_std_atomic)))]
|
||||
pub use std::sync::atomic::{
|
||||
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32,
|
||||
AtomicU8, AtomicUsize, Ordering,
|
||||
};
|
||||
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic64)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), no_target_has_atomic, not(no_std_atomic64)))]
|
||||
pub use std::sync::atomic::{AtomicI64, AtomicU64};
|
||||
|
||||
#[cfg(all(feature = "std", not(no_target_has_atomic)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_target_has_atomic)))]
|
||||
pub use std::sync::atomic::Ordering;
|
||||
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "8"))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_target_has_atomic), target_has_atomic = "8"))]
|
||||
pub use std::sync::atomic::{AtomicBool, AtomicI8, AtomicU8};
|
||||
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "16"))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_target_has_atomic), target_has_atomic = "16"))]
|
||||
pub use std::sync::atomic::{AtomicI16, AtomicU16};
|
||||
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "32"))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_target_has_atomic), target_has_atomic = "32"))]
|
||||
pub use std::sync::atomic::{AtomicI32, AtomicU32};
|
||||
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "64"))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_target_has_atomic), target_has_atomic = "64"))]
|
||||
pub use std::sync::atomic::{AtomicI64, AtomicU64};
|
||||
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "ptr"))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_target_has_atomic), target_has_atomic = "ptr"))]
|
||||
pub use std::sync::atomic::{AtomicIsize, AtomicUsize};
|
||||
|
||||
#[cfg(not(no_core_num_saturating))]
|
||||
@@ -164,7 +198,7 @@ macro_rules! crate_root {
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/private.rs"));
|
||||
|
||||
#[cfg(all(not(feature = "std"), no_core_error))]
|
||||
#[cfg(all(any(not(feature = "std"), target_os = "none"), no_core_error))]
|
||||
#[cfg_attr(all(docsrs, if_docsrs_then_no_serde_core), path = "core/std_error.rs")]
|
||||
mod std_error;
|
||||
};
|
||||
|
||||
+23
-22
@@ -226,12 +226,13 @@ macro_rules! num_as_copysign_self {
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
#[cfg(not(feature = "std"))]
|
||||
// On no_std or wasm32v1-none (target_os = "none"), use simple cast
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
{
|
||||
Ok(v as Self::Value)
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
{
|
||||
// Preserve sign of NaN. The `as` produces a nondeterministic sign.
|
||||
let sign = if v.is_sign_positive() { 1.0 } else { -1.0 };
|
||||
@@ -1107,7 +1108,7 @@ seq_impl!(
|
||||
);
|
||||
|
||||
seq_impl!(
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
HashSet<T: Eq + Hash, S: BuildHasher + Default>,
|
||||
seq,
|
||||
@@ -1563,7 +1564,7 @@ map_impl! {
|
||||
}
|
||||
|
||||
map_impl! {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
HashMap<K: Eq + Hash, V, S: BuildHasher + Default>,
|
||||
map,
|
||||
@@ -1781,10 +1782,10 @@ parse_socket_impl! {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
struct PathVisitor;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
impl<'a> Visitor<'a> for PathVisitor {
|
||||
type Value = &'a Path;
|
||||
|
||||
@@ -1809,7 +1810,7 @@ impl<'a> Visitor<'a> for PathVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl<'de: 'a, 'a> Deserialize<'de> for &'a Path {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
@@ -1820,10 +1821,10 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a Path {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
struct PathBufVisitor;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
impl<'de> Visitor<'de> for PathBufVisitor {
|
||||
type Value = PathBuf;
|
||||
|
||||
@@ -1864,7 +1865,7 @@ impl<'de> Visitor<'de> for PathBufVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl<'de> Deserialize<'de> for PathBuf {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
@@ -1876,7 +1877,7 @@ impl<'de> Deserialize<'de> for PathBuf {
|
||||
}
|
||||
|
||||
forwarded_impl! {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
(), Box<Path>, PathBuf::into_boxed_path
|
||||
}
|
||||
@@ -1887,17 +1888,17 @@ forwarded_impl! {
|
||||
//
|
||||
// #[derive(Deserialize)]
|
||||
// #[serde(variant_identifier)]
|
||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), any(unix, windows)))]
|
||||
variant_identifier! {
|
||||
OsStringKind (Unix; b"Unix"; 0, Windows; b"Windows"; 1)
|
||||
"`Unix` or `Windows`",
|
||||
OSSTR_VARIANTS
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), any(unix, windows)))]
|
||||
struct OsStringVisitor;
|
||||
|
||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), any(unix, windows)))]
|
||||
impl<'de> Visitor<'de> for OsStringVisitor {
|
||||
type Value = OsString;
|
||||
|
||||
@@ -1938,7 +1939,7 @@ impl<'de> Visitor<'de> for OsStringVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), any(unix, windows)))]
|
||||
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", any(unix, windows)))))]
|
||||
impl<'de> Deserialize<'de> for OsString {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
@@ -1970,7 +1971,7 @@ forwarded_impl! {
|
||||
}
|
||||
|
||||
forwarded_impl! {
|
||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), any(unix, windows)))]
|
||||
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", any(unix, windows)))))]
|
||||
(), Box<OsStr>, OsString::into_boxed_os_str
|
||||
}
|
||||
@@ -2105,13 +2106,13 @@ forwarded_impl! {
|
||||
}
|
||||
|
||||
forwarded_impl! {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
(T), Mutex<T>, Mutex::new
|
||||
}
|
||||
|
||||
forwarded_impl! {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
(T), RwLock<T>, RwLock::new
|
||||
}
|
||||
@@ -2266,7 +2267,7 @@ impl<'de> Deserialize<'de> for Duration {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl<'de> Deserialize<'de> for SystemTime {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
@@ -3099,7 +3100,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_std_atomic)))]
|
||||
macro_rules! atomic_impl {
|
||||
($($ty:ident $size:expr)*) => {
|
||||
$(
|
||||
@@ -3117,7 +3118,7 @@ macro_rules! atomic_impl {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_std_atomic)))]
|
||||
atomic_impl! {
|
||||
AtomicBool "8"
|
||||
AtomicI8 "8"
|
||||
@@ -3130,7 +3131,7 @@ atomic_impl! {
|
||||
AtomicUsize "ptr"
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", not(no_std_atomic64)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_std_atomic64)))]
|
||||
atomic_impl! {
|
||||
AtomicI64 "64"
|
||||
AtomicU64 "64"
|
||||
|
||||
@@ -122,13 +122,13 @@ mod ignored_any;
|
||||
mod impls;
|
||||
|
||||
pub use self::ignored_any::IgnoredAny;
|
||||
#[cfg(all(not(feature = "std"), no_core_error))]
|
||||
#[cfg(all(any(not(feature = "std"), target_os = "none"), no_core_error))]
|
||||
#[doc(no_inline)]
|
||||
pub use crate::std_error::Error as StdError;
|
||||
#[cfg(not(any(feature = "std", no_core_error)))]
|
||||
#[cfg(all(any(not(feature = "std"), target_os = "none"), not(no_core_error)))]
|
||||
#[doc(no_inline)]
|
||||
pub use core::error::Error as StdError;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[doc(no_inline)]
|
||||
pub use std::error::Error as StdError;
|
||||
|
||||
@@ -300,10 +300,10 @@ macro_rules! declare_error_trait {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
declare_error_trait!(Error: Sized + StdError);
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
declare_error_trait!(Error: Sized + Debug + Display);
|
||||
|
||||
/// `Unexpected` represents an unexpected invocation of any one of the `Visitor`
|
||||
|
||||
@@ -112,7 +112,7 @@ impl Debug for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl error::Error for Error {
|
||||
fn description(&self) -> &str {
|
||||
@@ -1160,7 +1160,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl<'de, T, S, E> IntoDeserializer<'de, E> for HashSet<T, S>
|
||||
where
|
||||
@@ -1588,7 +1588,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl<'de, K, V, S, E> IntoDeserializer<'de, E> for HashMap<K, V, S>
|
||||
where
|
||||
|
||||
@@ -37,7 +37,9 @@
|
||||
// Serde types in rustdoc of other crates get linked to here.
|
||||
#![doc(html_root_url = "https://docs.rs/serde_core/1.0.228")]
|
||||
// Support using Serde without the standard library!
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// Also force no_std on target_os = "none" (wasm32v1-none) even if std feature is enabled
|
||||
// This handles Cargo feature unification where std gets enabled for no_std targets
|
||||
#![cfg_attr(any(not(feature = "std"), target_os = "none"), no_std)]
|
||||
// Show which crate feature enables conditionally compiled APIs in documentation.
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, rustdoc_internals))]
|
||||
#![cfg_attr(docsrs, allow(internal_features))]
|
||||
@@ -100,9 +102,13 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
#[cfg(all(feature = "alloc", any(not(feature = "std"), target_os = "none")))]
|
||||
extern crate alloc;
|
||||
|
||||
// Explicitly import core crate for no_std targets (especially wasm32v1-none)
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate core;
|
||||
|
||||
#[macro_use]
|
||||
mod crate_root;
|
||||
#[macro_use]
|
||||
|
||||
@@ -18,7 +18,7 @@ impl ser::Error for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(not(no_diagnostic_namespace), diagnostic::do_not_recommend)]
|
||||
impl error::Error for Error {
|
||||
fn description(&self) -> &str {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::lib::*;
|
||||
|
||||
use crate::ser::{Error, Impossible, Serialize, Serializer};
|
||||
|
||||
impl Error for fmt::Error {
|
||||
|
||||
+12
-12
@@ -219,7 +219,7 @@ seq_impl! {
|
||||
}
|
||||
|
||||
seq_impl! {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
HashSet<T, H: BuildHasher>
|
||||
}
|
||||
@@ -450,7 +450,7 @@ map_impl! {
|
||||
}
|
||||
|
||||
map_impl! {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
HashMap<K: Eq + Hash, V, H: BuildHasher>
|
||||
}
|
||||
@@ -624,7 +624,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl<T> Serialize for Mutex<T>
|
||||
where
|
||||
@@ -641,7 +641,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl<T> Serialize for RwLock<T>
|
||||
where
|
||||
@@ -697,7 +697,7 @@ impl Serialize for Duration {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl Serialize for SystemTime {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
@@ -903,7 +903,7 @@ impl Serialize for net::SocketAddrV6 {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl Serialize for Path {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
@@ -917,7 +917,7 @@ impl Serialize for Path {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
impl Serialize for PathBuf {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
@@ -928,7 +928,7 @@ impl Serialize for PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), any(unix, windows)))]
|
||||
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", any(unix, windows)))))]
|
||||
impl Serialize for OsStr {
|
||||
#[cfg(unix)]
|
||||
@@ -951,7 +951,7 @@ impl Serialize for OsStr {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", any(unix, windows)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), any(unix, windows)))]
|
||||
#[cfg_attr(docsrs, doc(cfg(all(feature = "std", any(unix, windows)))))]
|
||||
impl Serialize for OsString {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
@@ -1006,7 +1006,7 @@ where
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_std_atomic)))]
|
||||
macro_rules! atomic_impl {
|
||||
($($ty:ident $size:expr)*) => {
|
||||
$(
|
||||
@@ -1025,7 +1025,7 @@ macro_rules! atomic_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", not(no_std_atomic)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_std_atomic)))]
|
||||
atomic_impl! {
|
||||
AtomicBool "8"
|
||||
AtomicI8 "8"
|
||||
@@ -1038,7 +1038,7 @@ atomic_impl! {
|
||||
AtomicUsize "ptr"
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "std", not(no_std_atomic64)))]
|
||||
#[cfg(all(feature = "std", not(target_os = "none"), not(no_std_atomic64)))]
|
||||
atomic_impl! {
|
||||
AtomicI64 "64"
|
||||
AtomicU64 "64"
|
||||
|
||||
@@ -115,13 +115,13 @@ mod impossible;
|
||||
|
||||
pub use self::impossible::Impossible;
|
||||
|
||||
#[cfg(all(not(feature = "std"), no_core_error))]
|
||||
#[cfg(all(any(not(feature = "std"), target_os = "none"), no_core_error))]
|
||||
#[doc(no_inline)]
|
||||
pub use crate::std_error::Error as StdError;
|
||||
#[cfg(not(any(feature = "std", no_core_error)))]
|
||||
#[cfg(all(any(not(feature = "std"), target_os = "none"), not(no_core_error)))]
|
||||
#[doc(no_inline)]
|
||||
pub use core::error::Error as StdError;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
#[doc(no_inline)]
|
||||
pub use std::error::Error as StdError;
|
||||
|
||||
@@ -188,10 +188,10 @@ macro_rules! declare_error_trait {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", not(target_os = "none")))]
|
||||
declare_error_trait!(Error: Sized + StdError);
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[cfg(any(not(feature = "std"), target_os = "none"))]
|
||||
declare_error_trait!(Error: Sized + Debug + Display);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user