review: Gate Result impls behind a feature gate

This commit is contained in:
Piotr Osiewicz
2025-06-06 11:52:50 +02:00
parent 43f5eb5c69
commit 3deb08946e
4 changed files with 20 additions and 6 deletions
+8 -3
View File
@@ -22,10 +22,10 @@ serde_derive = { version = "1", optional = true, path = "../serde_derive" }
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",
@@ -46,7 +46,7 @@ serde_derive = { version = "=1.0.219", path = "../serde_derive" }
### FEATURES #################################################################
[features]
default = ["std"]
default = ["std", "result"]
# Provide derive(Serialize, Deserialize) macros.
derive = ["serde_derive"]
@@ -70,3 +70,8 @@ alloc = ["serde_core/alloc"]
# 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 = ["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"]
+8 -3
View File
@@ -18,10 +18,10 @@ rust-version = "1.56"
serde = { version = "1", path = "../serde" }
[package.metadata.playground]
features = ["rc"]
features = ["rc", "result"]
[package.metadata.docs.rs]
features = ["rc", "unstable"]
features = ["rc", "result", "unstable"]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = [
"--generate-link-to-definition",
@@ -34,7 +34,7 @@ rustdoc-args = [
### FEATURES #################################################################
[features]
default = ["std"]
default = ["std", "result"]
# Provide impls for common standard library types like Vec<T> and HashMap<K, V>.
# Requires a dependency on the Rust standard library.
@@ -55,3 +55,8 @@ alloc = []
# 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 = []
# 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 = []
+2
View File
@@ -2975,6 +2975,8 @@ where
////////////////////////////////////////////////////////////////////////////////
#[cfg(feature = "result")]
#[cfg_attr(docsrs, doc(cfg(feature = "result")))]
impl<'de, T, E> Deserialize<'de> for Result<T, E>
where
T: Deserialize<'de>,
+2
View File
@@ -660,6 +660,8 @@ where
////////////////////////////////////////////////////////////////////////////////
#[cfg(feature = "result")]
#[cfg_attr(docsrs, doc(cfg(feature = "result")))]
impl<T, E> Serialize for Result<T, E>
where
T: Serialize,