diff --git a/Cargo.toml b/Cargo.toml index 3fe668e..e0c0860 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,13 +27,17 @@ default = [] [dev-dependencies] serde_json = "1.0" rand = "0.3" +rustc-serialize = "0.3" [dependencies] libc = "0.2" -rustc-serialize = "0.3" serde = "1.0" [dependencies.rand] version = "0.3" optional = true +[dependencies.rustc-serialize] +version = "0.3" +optional = true + diff --git a/src/key.rs b/src/key.rs index 72a75a4..b249d2b 100644 --- a/src/key.rs +++ b/src/key.rs @@ -17,7 +17,7 @@ use std::marker; #[cfg(any(test, feature = "rand"))] use rand::Rng; -use serialize::{Decoder, Decodable, Encoder, Encodable}; +#[cfg(any(test, feature = "rustc-serialize"))] use serialize::{Decoder, Decodable, Encoder, Encodable}; use serde::{Serialize, Deserialize, Serializer, Deserializer}; use super::{Secp256k1, ContextFlag}; @@ -254,6 +254,7 @@ impl PublicKey { } } +#[cfg(any(test, feature = "rustc-serialize"))] impl Decodable for PublicKey { fn decode(d: &mut D) -> Result { d.read_seq(|d, len| { @@ -292,6 +293,7 @@ impl From for PublicKey { } +#[cfg(any(test, feature = "rustc-serialize"))] impl Encodable for PublicKey { fn encode(&self, s: &mut S) -> Result<(), S::Error> { self.serialize().encode(s) diff --git a/src/lib.rs b/src/lib.rs index f09b76d..8cefe20 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,8 +40,8 @@ #[cfg(all(test, feature = "unstable"))] extern crate test; #[cfg(test)] extern crate serde_json as json; #[cfg(any(test, feature = "rand"))] extern crate rand; +#[cfg(any(test, feature = "rustc-serialize"))] extern crate rustc_serialize as serialize; -extern crate rustc_serialize as serialize; extern crate serde; extern crate libc; diff --git a/src/macros.rs b/src/macros.rs index 4f5b8d5..8a7df11 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -116,6 +116,7 @@ macro_rules! impl_array_newtype { } } + #[cfg(any(test, feature = "rustc-serialize"))] impl ::serialize::Decodable for $thing { fn decode(d: &mut D) -> Result<$thing, D::Error> { use serialize::Decodable; @@ -137,6 +138,7 @@ macro_rules! impl_array_newtype { } } + #[cfg(any(test, feature = "rustc-serialize"))] impl ::serialize::Encodable for $thing { fn encode(&self, s: &mut S) -> Result<(), S::Error> {