From e2d47a29e2f10be1fe5cc07d4229f45b0c1a84cb Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Wed, 9 Feb 2022 07:57:36 +0000 Subject: [PATCH] Remove unnecessary import statement The global context is already in scope in tests since we use a glob import. No clue why Clippy does not warn for this. Remove unnecessary import statement in test function. --- src/lib.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3ee86e4..159f637 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,22 @@ //! # } //! ``` //! +//! If the "global-context" feature is enabled you have access to an alternate API. +//! +//! ```rust +//! # #[cfg(all(feature="global-context", feature = "std", feature="rand-std", features = "bitcoin_hashes"))] { +//! use secp256k1::rand::thread_rng; +//! use secp256k1::{generate_keypair, Message}; +//! use secp256k1::hashes::sha256; +//! +//! let (secret_key, public_key) = generate_keypair(&mut thread_rng()); +//! let message = Message::from_hashed_data::("Hello World!".as_bytes()); +//! +//! let sig = secret_key.sign_ecdsa(&message, &secret_key); +//! assert!(sig.verify(&message, &public_key).is_ok()); +//! # } +//! ``` +//! //! The above code requires `rust-secp256k1` to be compiled with the `rand-std` and `bitcoin_hashes` //! feature enabled, to get access to [`generate_keypair`](struct.Secp256k1.html#method.generate_keypair) //! Alternately, keys and messages can be parsed from slices, like @@ -968,8 +984,6 @@ mod tests { #[cfg(feature = "global-context")] #[test] fn test_global_context() { - use super::SECP256K1; - let sk_data = hex!("e6dd32f8761625f105c39a39f19370b3521d845a12456d60ce44debd0a362641"); let sk = SecretKey::from_slice(&sk_data).unwrap(); let msg_data = hex!("a4965ca63b7d8562736ceec36dfa5a11bf426eb65be8ea3f7a49ae363032da0d");