| 1 |
macro_rules! crate_root { |
| 2 |
() => { |
| 3 |
/// A facade around all the types we need from the `std`, `core`, and `alloc` |
| 4 |
/// crates. This avoids elaborate import wrangling having to happen in every |
| 5 |
/// module. |
| 6 |
mod lib { |
| 7 |
mod core { |
| 8 |
#[cfg(not(feature = "std"))] |
| 9 |
pub use core::*; |
| 10 |
#[cfg(feature = "std")] |
| 11 |
pub use std::*; |
| 12 |
} |
| 13 |
|
| 14 |
pub use self::core::{f32, f64}; |
| 15 |
pub use self::core::{iter, num, str}; |
| 16 |
|
| 17 |
#[cfg(any(feature = "std", feature = "alloc"))] |
| 18 |
pub use self::core::{cmp, mem}; |
| 19 |
|
| 20 |
pub use self::core::cell::{Cell, RefCell}; |
| 21 |
pub use self::core::cmp::Reverse; |
| 22 |
pub use self::core::fmt::{self, Debug, Display, Write as FmtWrite}; |
| 23 |
pub use self::core::marker::PhantomData; |
| 24 |
pub use self::core::num::Wrapping; |
| 25 |
pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo}; |
| 26 |
pub use self::core::result; |
| 27 |
pub use self::core::time::Duration; |
| 28 |
|
| 29 |
#[cfg(all(feature = "alloc", not(feature = "std")))] |
| 30 |
pub use alloc::borrow::{Cow, ToOwned}; |
| 31 |
#[cfg(feature = "std")] |
| 32 |
pub use std::borrow::{Cow, ToOwned}; |
| 33 |
|
| 34 |
#[cfg(all(feature = "alloc", not(feature = "std")))] |
| 35 |
pub use alloc::string::{String, ToString}; |
| 36 |
#[cfg(feature = "std")] |
| 37 |
pub use std::string::{String, ToString}; |
| 38 |
|
| 39 |
#[cfg(all(feature = "alloc", not(feature = "std")))] |
| 40 |
pub use alloc::vec::Vec; |
| 41 |
#[cfg(feature = "std")] |
| 42 |
pub use std::vec::Vec; |
| 43 |
|
| 44 |
#[cfg(all(feature = "alloc", not(feature = "std")))] |
| 45 |
pub use alloc::boxed::Box; |
| 46 |
#[cfg(feature = "std")] |
| 47 |
pub use std::boxed::Box; |
| 48 |
|
| 49 |
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))] |
| 50 |
pub use alloc::rc::{Rc, Weak as RcWeak}; |
| 51 |
#[cfg(all(feature = "rc", feature = "std"))] |
| 52 |
pub use std::rc::{Rc, Weak as RcWeak}; |
| 53 |
|
| 54 |
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))] |
| 55 |
pub use alloc::sync::{Arc, Weak as ArcWeak}; |
| 56 |
#[cfg(all(feature = "rc", feature = "std"))] |
| 57 |
pub use std::sync::{Arc, Weak as ArcWeak}; |
| 58 |
|
| 59 |
#[cfg(all(feature = "alloc", not(feature = "std")))] |
| 60 |
pub use alloc::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque}; |
| 61 |
#[cfg(feature = "std")] |
| 62 |
pub use std::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque}; |
| 63 |
|
| 64 |
#[cfg(all(not(no_core_cstr), not(feature = "std")))] |
| 65 |
pub use self::core::ffi::CStr; |
| 66 |
#[cfg(feature = "std")] |
| 67 |
pub use std::ffi::CStr; |
| 68 |
|
| 69 |
#[cfg(all(not(no_core_cstr), feature = "alloc", not(feature = "std")))] |
| 70 |
pub use alloc::ffi::CString; |
| 71 |
#[cfg(feature = "std")] |
| 72 |
pub use std::ffi::CString; |
| 73 |
|
| 74 |
#[cfg(all(not(no_core_net), not(feature = "std")))] |
| 75 |
pub use self::core::net; |
| 76 |
#[cfg(feature = "std")] |
| 77 |
pub use std::net; |
| 78 |
|
| 79 |
#[cfg(feature = "std")] |
| 80 |
pub use std::error; |
| 81 |
|
| 82 |
#[cfg(feature = "std")] |
| 83 |
pub use std::collections::{HashMap, HashSet}; |
| 84 |
#[cfg(feature = "std")] |
| 85 |
pub use std::ffi::{OsStr, OsString}; |
| 86 |
#[cfg(feature = "std")] |
| 87 |
pub use std::hash::{BuildHasher, Hash}; |
| 88 |
#[cfg(feature = "std")] |
| 89 |
pub use std::io::Write; |
| 90 |
#[cfg(feature = "std")] |
| 91 |
pub use std::path::{Path, PathBuf}; |
| 92 |
#[cfg(feature = "std")] |
| 93 |
pub use std::sync::{Mutex, RwLock}; |
| 94 |
#[cfg(feature = "std")] |
| 95 |
pub use std::time::{SystemTime, UNIX_EPOCH}; |
| 96 |
|
| 97 |
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))] |
| 98 |
pub use std::sync::atomic::{ |
| 99 |
AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, |
| 100 |
AtomicU8, AtomicUsize, Ordering, |
| 101 |
}; |
| 102 |
#[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic64)))] |
| 103 |
pub use std::sync::atomic::{AtomicI64, AtomicU64}; |
| 104 |
|
| 105 |
#[cfg(all(feature = "std", not(no_target_has_atomic)))] |
| 106 |
pub use std::sync::atomic::Ordering; |
| 107 |
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "8"))] |
| 108 |
pub use std::sync::atomic::{AtomicBool, AtomicI8, AtomicU8}; |
| 109 |
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "16"))] |
| 110 |
pub use std::sync::atomic::{AtomicI16, AtomicU16}; |
| 111 |
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "32"))] |
| 112 |
pub use std::sync::atomic::{AtomicI32, AtomicU32}; |
| 113 |
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "64"))] |
| 114 |
pub use std::sync::atomic::{AtomicI64, AtomicU64}; |
| 115 |
#[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "ptr"))] |
| 116 |
pub use std::sync::atomic::{AtomicIsize, AtomicUsize}; |
| 117 |
|
| 118 |
#[cfg(not(no_core_num_saturating))] |
| 119 |
pub use self::core::num::Saturating; |
| 120 |
} |
| 121 |
|
| 122 |
// None of this crate's error handling needs the `From::from` error conversion |
| 123 |
// performed implicitly by the `?` operator or the standard library's `try!` |
| 124 |
// macro. This simplified macro gives a 5.5% improvement in compile time |
| 125 |
// compared to standard `try!`, and 9% improvement compared to `?`. |
| 126 |
macro_rules! tri { |
| 127 |
($expr:expr) => { |
| 128 |
match $expr { |
| 129 |
Ok(val) => val, |
| 130 |
Err(err) => return Err(err), |
| 131 |
} |
| 132 |
}; |
| 133 |
} |
| 134 |
|
| 135 |
#[cfg_attr(all(docsrs, if_docsrs_then_no_serde_core), path = "core/de/mod.rs")] |
| 136 |
pub mod de; |
| 137 |
#[cfg_attr(all(docsrs, if_docsrs_then_no_serde_core), path = "core/ser/mod.rs")] |
| 138 |
pub mod ser; |
| 139 |
|
| 140 |
#[cfg_attr(all(docsrs, if_docsrs_then_no_serde_core), path = "core/format.rs")] |
| 141 |
mod format; |
| 142 |
|
| 143 |
#[doc(inline)] |
| 144 |
pub use crate::de::{Deserialize, Deserializer}; |
| 145 |
#[doc(inline)] |
| 146 |
pub use crate::ser::{Serialize, Serializer}; |
| 147 |
|
| 148 |
// Used by generated code. Not public API. |
| 149 |
#[doc(hidden)] |
| 150 |
#[cfg_attr( |
| 151 |
all(docsrs, if_docsrs_then_no_serde_core), |
| 152 |
path = "core/private/mod.rs" |
| 153 |
)] |
| 154 |
mod private; |
| 155 |
|
| 156 |
// Used by declarative macro generated code. Not public API. |
| 157 |
#[doc(hidden)] |
| 158 |
pub mod __private { |
| 159 |
#[doc(hidden)] |
| 160 |
pub use crate::private::doc; |
| 161 |
#[doc(hidden)] |
| 162 |
pub use core::result::Result; |
| 163 |
} |
| 164 |
|
| 165 |
include!(concat!(env!("OUT_DIR"), "/private.rs")); |
| 166 |
|
| 167 |
#[cfg(all(not(feature = "std"), no_core_error))] |
| 168 |
#[cfg_attr(all(docsrs, if_docsrs_then_no_serde_core), path = "core/std_error.rs")] |
| 169 |
mod std_error; |
| 170 |
}; |
| 171 |
} |