Merge pull request #864 from serde-rs/rc

Put rc impls behind a cfg
This commit is contained in:
David Tolnay
2017-04-10 17:20:38 -07:00
committed by GitHub
4 changed files with 22 additions and 17 deletions
+5
View File
@@ -64,6 +64,11 @@ alloc = ["unstable"]
# https://doc.rust-lang.org/collections/
collections = ["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 = []
# Get serde_derive picked up by the Integer 32 playground. Not public API.
#
# http://play.integer32.com/
+6 -6
View File
@@ -28,14 +28,14 @@ use std::ffi::{CString, OsString};
#[cfg(all(feature = "std", feature = "unstable"))]
use std::ffi::CStr;
#[cfg(feature = "std")]
#[cfg(all(feature = "rc", feature = "std"))]
use std::rc::Rc;
#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))]
use alloc::rc::Rc;
#[cfg(feature = "std")]
#[cfg(all(feature = "rc", feature = "std"))]
use std::sync::Arc;
#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))]
use alloc::arc::Arc;
#[cfg(all(feature = "alloc", not(feature = "std")))]
@@ -1141,7 +1141,7 @@ impl<'de> Deserialize<'de> for Box<str> {
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc<T> {
fn deserialize<D>(deserializer: D) -> Result<Arc<T>, D::Error>
where D: Deserializer<'de>
@@ -1151,7 +1151,7 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Arc<T> {
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Rc<T> {
fn deserialize<D>(deserializer: D) -> Result<Rc<T>, D::Error>
where D: Deserializer<'de>
+6 -6
View File
@@ -17,16 +17,16 @@ use core::hash::{Hash, BuildHasher};
use std::{net, ops, path};
#[cfg(feature = "std")]
use std::ffi::{CString, CStr, OsString, OsStr};
#[cfg(feature = "std")]
#[cfg(all(feature = "rc", feature = "std"))]
use std::rc::Rc;
#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))]
use alloc::rc::Rc;
#[cfg(feature = "std")]
use std::time::Duration;
#[cfg(feature = "std")]
#[cfg(all(feature = "rc", feature = "std"))]
use std::sync::Arc;
#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))]
use alloc::arc::Arc;
#[cfg(all(feature = "alloc", not(feature = "std")))]
@@ -555,7 +555,7 @@ impl<T: ?Sized> Serialize for Box<T>
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
impl<T> Serialize for Rc<T>
where T: Serialize
{
@@ -567,7 +567,7 @@ impl<T> Serialize for Rc<T>
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))]
impl<T> Serialize for Arc<T>
where T: Serialize
{
+5 -5
View File
@@ -29,7 +29,7 @@ if [ -n "${CLIPPY}" ]; then
fi
cd "$DIR/serde"
cargo clippy --features unstable -- -Dclippy
cargo clippy --features 'rc unstable' -- -Dclippy
cd "$DIR/serde_derive"
cargo clippy --features unstable -- -Dclippy
@@ -47,7 +47,7 @@ else
channel build --no-default-features
channel build --no-default-features --features alloc
channel build --no-default-features --features collections
channel test --features unstable
channel test --features 'rc unstable'
cd "$DIR/test_suite/deps"
channel build
cd "$DIR/test_suite"
@@ -58,19 +58,19 @@ else
CHANNEL=beta
cargo clean
cd "$DIR/serde"
channel build
channel build --features rc
cd "$DIR/test_suite"
channel test
CHANNEL=stable
cargo clean
cd "$DIR/serde"
channel build
channel build --features rc
channel build --no-default-features
CHANNEL=1.13.0
cargo clean
cd "$DIR/serde"
channel build
channel build --features rc
channel build --no-default-features
fi