Skip to content

Commit f3688ec

Browse files
committed
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`.
1 parent ae3e06f commit f3688ec

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/key.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use ffi::{self, CPtr};
3535
/// Basic usage:
3636
///
3737
/// ```
38-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
38+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
3939
/// use secp256k1::{rand, Secp256k1, SecretKey};
4040
///
4141
/// let secp = Secp256k1::new();
@@ -129,7 +129,7 @@ impl SecretKey {
129129
/// # Examples
130130
///
131131
/// ```
132-
/// # #[cfg(feature="rand")] {
132+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
133133
/// use secp256k1::{rand, SecretKey};
134134
/// let secret_key = SecretKey::new(&mut rand::thread_rng());
135135
/// # }
@@ -185,7 +185,7 @@ impl SecretKey {
185185
/// # Examples
186186
///
187187
/// ```
188-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
188+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
189189
/// use secp256k1::{rand, Secp256k1, SecretKey, KeyPair};
190190
///
191191
/// let secp = Secp256k1::new();
@@ -329,7 +329,7 @@ impl PublicKey {
329329
/// # Examples
330330
///
331331
/// ```
332-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
332+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
333333
/// use secp256k1::{rand, Secp256k1, SecretKey, PublicKey};
334334
///
335335
/// let secp = Secp256k1::new();
@@ -377,7 +377,7 @@ impl PublicKey {
377377
/// # Examples
378378
///
379379
/// ```
380-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
380+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
381381
/// use secp256k1::{rand, Secp256k1, PublicKey, KeyPair};
382382
///
383383
/// let secp = Secp256k1::new();
@@ -508,7 +508,7 @@ impl PublicKey {
508508
/// # Examples
509509
///
510510
/// ```
511-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
511+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
512512
/// use secp256k1::{rand, Secp256k1};
513513
///
514514
/// let secp = Secp256k1::new();
@@ -534,7 +534,7 @@ impl PublicKey {
534534
/// # Examples
535535
///
536536
/// ```
537-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
537+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
538538
/// use secp256k1::{rand, Secp256k1, PublicKey};
539539
///
540540
/// let secp = Secp256k1::new();
@@ -650,7 +650,7 @@ impl Ord for PublicKey {
650650
/// Basic usage:
651651
///
652652
/// ```
653-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
653+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
654654
/// use secp256k1::{rand, KeyPair, Secp256k1};
655655
///
656656
/// let secp = Secp256k1::new();
@@ -744,7 +744,7 @@ impl KeyPair {
744744
/// # Examples
745745
///
746746
/// ```
747-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
747+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
748748
/// use secp256k1::{rand, Secp256k1, SecretKey, KeyPair};
749749
///
750750
/// let secp = Secp256k1::new();
@@ -790,7 +790,7 @@ impl KeyPair {
790790
/// # Examples
791791
///
792792
/// ```
793-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
793+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
794794
/// use secp256k1::{Secp256k1, KeyPair};
795795
/// use secp256k1::rand::{RngCore, thread_rng};
796796
///
@@ -914,7 +914,7 @@ impl<'de> ::serde::Deserialize<'de> for KeyPair {
914914
/// Basic usage:
915915
///
916916
/// ```
917-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
917+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
918918
/// use secp256k1::{rand, Secp256k1, KeyPair, XOnlyPublicKey};
919919
///
920920
/// let secp = Secp256k1::new();
@@ -1042,7 +1042,7 @@ impl XOnlyPublicKey {
10421042
/// # Examples
10431043
///
10441044
/// ```
1045-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
1045+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
10461046
/// use secp256k1::{Secp256k1, KeyPair};
10471047
/// use secp256k1::rand::{RngCore, thread_rng};
10481048
///
@@ -1107,7 +1107,7 @@ impl XOnlyPublicKey {
11071107
/// # Examples
11081108
///
11091109
/// ```
1110-
/// # #[cfg(all(feature = "rand", any(feature = "alloc", feature = "std")))] {
1110+
/// # #[cfg(all(feature = "rand-std", any(feature = "alloc", feature = "std")))] {
11111111
/// use secp256k1::{Secp256k1, KeyPair};
11121112
/// use secp256k1::rand::{thread_rng, RngCore};
11131113
///

0 commit comments

Comments
 (0)