diff --git a/src/key.rs b/src/key.rs index 2c18dbf..a5fcfa9 100644 --- a/src/key.rs +++ b/src/key.rs @@ -128,12 +128,12 @@ impl PublicKey { unsafe { // We can assume the return value because it's not possible to construct // an invalid `SecretKey` without transmute trickery or something - assert_eq!(ffi::secp256k1_ec_pubkey_create( - secp.ctx, - pk.as_mut_ptr(), &mut len, - sk.as_ptr(), compressed), 1); + let res = ffi::secp256k1_ec_pubkey_create(secp.ctx, + pk.as_mut_ptr(), &mut len, + sk.as_ptr(), compressed); + debug_assert_eq!(res, 1); } - assert_eq!(len as usize, pk.len()); + debug_assert_eq!(len as usize, pk.len()); pk } @@ -406,7 +406,7 @@ impl Deserialize for PublicKey { fn visit_seq(&mut self, mut v: V) -> Result where V: de::SeqVisitor { - assert!(constants::UNCOMPRESSED_PUBLIC_KEY_SIZE >= constants::COMPRESSED_PUBLIC_KEY_SIZE); + debug_assert!(constants::UNCOMPRESSED_PUBLIC_KEY_SIZE >= constants::COMPRESSED_PUBLIC_KEY_SIZE); unsafe { use std::mem; diff --git a/src/lib.rs b/src/lib.rs index 2d3a91d..34f7805 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,9 +56,6 @@ pub mod constants; pub mod ffi; pub mod key; -/// I dunno where else to put this.. -fn assert_type_is_copy() { } - /// A tag used for recovering the public key from a compact signature #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct RecoveryId(i32); @@ -269,7 +266,7 @@ impl Secp256k1 { return Err(Error::SignFailed); } // This assertation is probably too late :) - assert!(len as usize <= constants::MAX_SIGNATURE_SIZE); + debug_assert!(len as usize <= constants::MAX_SIGNATURE_SIZE); }; Ok(Signature(len as usize, sig)) } @@ -306,7 +303,7 @@ impl Secp256k1 { recid) != 1 { return Err(Error::InvalidSignature); } - assert_eq!(len as usize, pk.len()); + debug_assert_eq!(len as usize, pk.len()); }; Ok(pk) } diff --git a/src/macros.rs b/src/macros.rs index 0d88f62..59c0853 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -116,8 +116,6 @@ macro_rules! impl_array_newtype { fn decode(d: &mut D) -> Result<$thing, D::Error> { use serialize::Decodable; - ::assert_type_is_copy::<$ty>(); - d.read_seq(|d, len| { if len != $len { Err(d.error("Invalid length"))