From f3688ecf5690a3a1b3738745a1ca244f3778fc60 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 1 Feb 2022 14:00:10 +1100 Subject: [PATCH] Use rand-std in key rustdoc examples Seems there is a bug in cargo, the tests in `key.rs` run successfully but AFAICT they should fail. Here is an example, running `cargo test --features=rand` should make this test fail but it doesn't? ``` /// Secret 256-bit key used as `x` in an ECDSA signature. /// /// # Examples /// /// Basic usage: /// /// ``` /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, SecretKey}; /// /// let secp = Secp256k1::new(); /// let secret_key = SecretKey::new(&mut rand::thread_rng()); /// # } /// ``` Anywho, use the correct feature gate: `rand-std`. --- src/key.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/key.rs b/src/key.rs index 97ddc21..2ce01ab 100644 --- a/src/key.rs +++ b/src/key.rs @@ -35,7 +35,7 @@ use ffi::{self, CPtr}; /// Basic usage: /// /// ``` -/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { +/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, SecretKey}; /// /// let secp = Secp256k1::new(); @@ -129,7 +129,7 @@ impl SecretKey { /// # Examples /// /// ``` - /// # #[cfg(feature="rand")] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, SecretKey}; /// let secret_key = SecretKey::new(&mut rand::thread_rng()); /// # } @@ -185,7 +185,7 @@ impl SecretKey { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, SecretKey, KeyPair}; /// /// let secp = Secp256k1::new(); @@ -329,7 +329,7 @@ impl PublicKey { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, SecretKey, PublicKey}; /// /// let secp = Secp256k1::new(); @@ -377,7 +377,7 @@ impl PublicKey { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, PublicKey, KeyPair}; /// /// let secp = Secp256k1::new(); @@ -508,7 +508,7 @@ impl PublicKey { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1}; /// /// let secp = Secp256k1::new(); @@ -534,7 +534,7 @@ impl PublicKey { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, PublicKey}; /// /// let secp = Secp256k1::new(); @@ -650,7 +650,7 @@ impl Ord for PublicKey { /// Basic usage: /// /// ``` -/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { +/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, KeyPair, Secp256k1}; /// /// let secp = Secp256k1::new(); @@ -744,7 +744,7 @@ impl KeyPair { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, SecretKey, KeyPair}; /// /// let secp = Secp256k1::new(); @@ -790,7 +790,7 @@ impl KeyPair { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{Secp256k1, KeyPair}; /// use secp256k1::rand::{RngCore, thread_rng}; /// @@ -914,7 +914,7 @@ impl<'de> ::serde::Deserialize<'de> for KeyPair { /// Basic usage: /// /// ``` -/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { +/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{rand, Secp256k1, KeyPair, XOnlyPublicKey}; /// /// let secp = Secp256k1::new(); @@ -1042,7 +1042,7 @@ impl XOnlyPublicKey { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{Secp256k1, KeyPair}; /// use secp256k1::rand::{RngCore, thread_rng}; /// @@ -1107,7 +1107,7 @@ impl XOnlyPublicKey { /// # Examples /// /// ``` - /// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] { + /// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] { /// use secp256k1::{Secp256k1, KeyPair}; /// use secp256k1::rand::{thread_rng, RngCore}; ///