-
-
Notifications
You must be signed in to change notification settings - Fork 873
feat: Extract serde_core out of serde crate #2608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
f386930
5fcfbed
43f5eb5
3deb089
f9baf39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| [workspace] | ||
| members = [ | ||
| "serde", | ||
| "serde_core", | ||
| "serde_derive", | ||
| "serde_derive_internals", | ||
| "test_suite", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,16 +15,17 @@ repository = "https://github.com/serde-rs/serde" | |
| rust-version = "1.56" | ||
|
|
||
| [dependencies] | ||
| serde_core = { version = "=1.0.219", path = "../serde_core", default-features = false } | ||
| serde_derive = { version = "1", optional = true, path = "../serde_derive" } | ||
|
|
||
| [dev-dependencies] | ||
| serde_derive = { version = "1", path = "../serde_derive" } | ||
|
|
||
| [package.metadata.playground] | ||
| features = ["derive", "rc"] | ||
| features = ["derive", "rc", "result"] | ||
|
|
||
| [package.metadata.docs.rs] | ||
| features = ["derive", "rc", "unstable"] | ||
| features = ["derive", "rc", "result", "unstable"] | ||
| targets = ["x86_64-unknown-linux-gnu"] | ||
| rustdoc-args = [ | ||
| "--generate-link-to-definition", | ||
|
|
@@ -45,27 +46,32 @@ serde_derive = { version = "=1.0.219", path = "../serde_derive" } | |
| ### FEATURES ################################################################# | ||
|
|
||
| [features] | ||
| default = ["std"] | ||
| default = ["std", "result"] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having |
||
|
|
||
| # Provide derive(Serialize, Deserialize) macros. | ||
| derive = ["serde_derive"] | ||
|
|
||
| # Provide impls for common standard library types like Vec<T> and HashMap<K, V>. | ||
| # Requires a dependency on the Rust standard library. | ||
| std = [] | ||
| std = ["serde_core/std"] | ||
|
|
||
| # Provide impls for types that require unstable functionality. For tracking and | ||
| # discussion of unstable functionality please refer to this issue: | ||
| # | ||
| # https://github.com/serde-rs/serde/issues/812 | ||
| unstable = [] | ||
| unstable = ["serde_core/unstable"] | ||
|
|
||
| # Provide impls for types in the Rust core allocation and collections library | ||
| # including String, Box<T>, Vec<T>, and Cow<T>. This is a subset of std but may | ||
| # be enabled without depending on all of std. | ||
| alloc = [] | ||
| alloc = ["serde_core/alloc"] | ||
|
|
||
| # Opt into impls for Rc<T> and Arc<T>. Serializing and deserializing these types | ||
| # does not preserve identity and may result in multiple copies of the same data. | ||
| # Be sure that this is what you want before enabling this feature. | ||
| rc = [] | ||
| rc = ["serde_core/rc"] | ||
|
|
||
| # Provide impls for Result<T, E>. Enabling these impls allows for serialization | ||
| # and deserialization of Result types, which may be useful in certain contexts | ||
| # but could lead to confusion if ? or unwrap are overused. | ||
| result = ["serde_core/result"] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -175,23 +175,18 @@ mod lib { | |||||
| } | ||||||
|
|
||||||
| pub use self::core::{f32, f64}; | ||||||
| pub use self::core::{iter, num, ptr, str}; | ||||||
| pub use self::core::{ptr, str}; | ||||||
|
|
||||||
| #[cfg(any(feature = "std", feature = "alloc"))] | ||||||
| pub use self::core::{cmp, mem, slice}; | ||||||
| pub use self::core::slice; | ||||||
|
|
||||||
| pub use self::core::cell::{Cell, RefCell}; | ||||||
| pub use self::core::clone; | ||||||
| pub use self::core::cmp::Reverse; | ||||||
| pub use self::core::convert; | ||||||
| pub use self::core::default; | ||||||
| pub use self::core::fmt::{self, Debug, Display, Write as FmtWrite}; | ||||||
| pub use self::core::marker::{self, PhantomData}; | ||||||
| pub use self::core::num::Wrapping; | ||||||
| pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo}; | ||||||
| pub use self::core::option; | ||||||
| pub use self::core::result; | ||||||
| pub use self::core::time::Duration; | ||||||
|
|
||||||
| #[cfg(all(feature = "alloc", not(feature = "std")))] | ||||||
| pub use alloc::borrow::{Cow, ToOwned}; | ||||||
|
|
@@ -213,83 +208,15 @@ mod lib { | |||||
| #[cfg(feature = "std")] | ||||||
| pub use std::boxed::Box; | ||||||
|
|
||||||
| #[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))] | ||||||
| pub use alloc::rc::{Rc, Weak as RcWeak}; | ||||||
| #[cfg(all(feature = "rc", feature = "std"))] | ||||||
| pub use std::rc::{Rc, Weak as RcWeak}; | ||||||
|
|
||||||
| #[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))] | ||||||
| pub use alloc::sync::{Arc, Weak as ArcWeak}; | ||||||
| #[cfg(all(feature = "rc", feature = "std"))] | ||||||
| pub use std::sync::{Arc, Weak as ArcWeak}; | ||||||
|
|
||||||
| #[cfg(all(feature = "alloc", not(feature = "std")))] | ||||||
| pub use alloc::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque}; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque}; | ||||||
|
|
||||||
| #[cfg(all(not(no_core_cstr), not(feature = "std")))] | ||||||
| pub use self::core::ffi::CStr; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::ffi::CStr; | ||||||
|
|
||||||
| #[cfg(all(not(no_core_cstr), feature = "alloc", not(feature = "std")))] | ||||||
| pub use alloc::ffi::CString; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::ffi::CString; | ||||||
|
|
||||||
| #[cfg(all(not(no_core_net), not(feature = "std")))] | ||||||
| pub use self::core::net; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::net; | ||||||
|
|
||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::error; | ||||||
|
|
||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::collections::{HashMap, HashSet}; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::ffi::{OsStr, OsString}; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::hash::{BuildHasher, Hash}; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::io::Write; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::path::{Path, PathBuf}; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::sync::{Mutex, RwLock}; | ||||||
| #[cfg(feature = "std")] | ||||||
| pub use std::time::{SystemTime, UNIX_EPOCH}; | ||||||
|
|
||||||
| #[cfg(all(feature = "std", 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)))] | ||||||
| pub use std::sync::atomic::{AtomicI64, AtomicU64}; | ||||||
|
|
||||||
| #[cfg(all(feature = "std", not(no_target_has_atomic)))] | ||||||
| pub use std::sync::atomic::Ordering; | ||||||
| #[cfg(all(feature = "std", 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"))] | ||||||
| pub use std::sync::atomic::{AtomicI16, AtomicU16}; | ||||||
| #[cfg(all(feature = "std", 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"))] | ||||||
| pub use std::sync::atomic::{AtomicI64, AtomicU64}; | ||||||
| #[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "ptr"))] | ||||||
| pub use std::sync::atomic::{AtomicIsize, AtomicUsize}; | ||||||
|
|
||||||
| #[cfg(not(no_core_num_saturating))] | ||||||
| pub use self::core::num::Saturating; | ||||||
| } | ||||||
|
|
||||||
| // None of this crate's error handling needs the `From::from` error conversion | ||||||
| // performed implicitly by the `?` operator or the standard library's `try!` | ||||||
| // macro. This simplified macro gives a 5.5% improvement in compile time | ||||||
| // compared to standard `try!`, and 9% improvement compared to `?`. | ||||||
| #[allow(unused_macros)] | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| macro_rules! tri { | ||||||
| ($expr:expr) => { | ||||||
| match $expr { | ||||||
|
|
@@ -301,33 +228,17 @@ macro_rules! tri { | |||||
|
|
||||||
| //////////////////////////////////////////////////////////////////////////////// | ||||||
|
|
||||||
| #[macro_use] | ||||||
| mod macros; | ||||||
|
|
||||||
| #[macro_use] | ||||||
| mod integer128; | ||||||
|
|
||||||
| pub mod de; | ||||||
| pub mod ser; | ||||||
|
|
||||||
| mod format; | ||||||
|
|
||||||
| #[doc(inline)] | ||||||
| pub use crate::de::{Deserialize, Deserializer}; | ||||||
| #[doc(inline)] | ||||||
| pub use crate::ser::{Serialize, Serializer}; | ||||||
| pub use serde_core::*; | ||||||
|
|
||||||
| // Used by generated code and doc tests. Not public API. | ||||||
| #[doc(hidden)] | ||||||
| #[path = "private/mod.rs"] | ||||||
| pub mod __private; | ||||||
|
|
||||||
| #[path = "de/seed.rs"] | ||||||
| mod seed; | ||||||
|
|
||||||
| #[cfg(all(not(feature = "std"), no_core_error))] | ||||||
| mod std_error; | ||||||
|
|
||||||
| // Re-export #[derive(Serialize, Deserialize)]. | ||||||
| // | ||||||
| // The reason re-exporting is not enabled by default is that disabling it would | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer used.