a189942c64 Use doc_auto_cfg (Tobin C. Harding)

Pull request description:

  If we use `#![cfg_attr(docsrs, feature(doc_auto_cfg))]` instead of `#![cfg_attr(docsrs, feature(doc_cfg))]` we no longer need to manually mark types with `#[cfg_attr(docsrs, doc(cfg(feature = "std")))]`.

  Sweeeeeet.

  Props to pezcore for the lesson :)

ACKs for top commit:
  apoelstra:
    ACK a189942c64
  Kixunil:
    ACK a189942c64

Tree-SHA512: 1ced1e09f5d1733b362b83ca650d3f52c89eb57e78e8437f74c496d89776548f8c50feab6750352342e2abe680434681de2c126ce36a81dda21397b9695d4d4e
This commit is contained in:
Andrew Poelstra 2023-03-30 16:02:07 +00:00
commit 895db71156
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
38 changed files with 3 additions and 101 deletions

View File

@ -126,7 +126,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -181,7 +181,6 @@ impl fmt::Display for ParseAmountError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for ParseAmountError { impl std::error::Error for ParseAmountError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::ParseAmountError::*; use self::ParseAmountError::*;
@ -1160,7 +1159,6 @@ mod private {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
pub mod serde { pub mod serde {
// methods are implementation of a standardized serde-specific signature // methods are implementation of a standardized serde-specific signature
#![allow(missing_docs)] #![allow(missing_docs)]

View File

@ -255,7 +255,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -38,7 +38,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -79,7 +79,6 @@ impl Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -211,7 +211,6 @@ impl FromStr for ChildNumber {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> serde::Deserialize<'de> for ChildNumber { impl<'de> serde::Deserialize<'de> for ChildNumber {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
@ -222,7 +221,6 @@ impl<'de> serde::Deserialize<'de> for ChildNumber {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl serde::Serialize for ChildNumber { impl serde::Serialize for ChildNumber {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
@ -482,7 +480,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -366,7 +366,6 @@ impl fmt::Display for Bip34Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Bip34Error { impl std::error::Error for Bip34Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Bip34Error::*; use self::Bip34Error::*;

View File

@ -569,7 +569,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;
@ -621,7 +620,6 @@ impl fmt::Display for ConversionError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for ConversionError {} impl std::error::Error for ConversionError {}
/// Describes the two types of locking, lock-by-blockheight and lock-by-blocktime. /// Describes the two types of locking, lock-by-blockheight and lock-by-blocktime.
@ -664,7 +662,6 @@ impl fmt::Display for OperationError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for OperationError {} impl std::error::Error for OperationError {}
#[cfg(test)] #[cfg(test)]

View File

@ -325,7 +325,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -422,7 +422,6 @@ impl From<u8> for All {
debug_from_display!(All); debug_from_display!(All);
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl serde::Serialize for All { impl serde::Serialize for All {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where

View File

@ -368,7 +368,6 @@ impl Script {
/// * `amount` - The amount this script guards. /// * `amount` - The amount this script guards.
/// * `spending_tx` - The transaction that attempts to spend the output holding this script. /// * `spending_tx` - The transaction that attempts to spend the output holding this script.
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
pub fn verify( pub fn verify(
&self, &self,
index: usize, index: usize,
@ -386,7 +385,6 @@ impl Script {
/// * `spending_tx` - The transaction that attempts to spend the output holding this script. /// * `spending_tx` - The transaction that attempts to spend the output holding this script.
/// * `flags` - Verification flags, see [`bitcoinconsensus::VERIFY_ALL`] and similar. /// * `flags` - Verification flags, see [`bitcoinconsensus::VERIFY_ALL`] and similar.
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
pub fn verify_with_flags<F: Into<u32>>( pub fn verify_with_flags<F: Into<u32>>(
&self, &self,
index: usize, index: usize,
@ -502,5 +500,4 @@ delegate_index!(
RangeToInclusive<usize> RangeToInclusive<usize>
); );
#[cfg(rust_v_1_53)] #[cfg(rust_v_1_53)]
#[cfg_attr(docsrs, doc(cfg(rust_v_1_53)))]
delegate_index!((Bound<usize>, Bound<usize>)); delegate_index!((Bound<usize>, Bound<usize>));

View File

@ -273,7 +273,6 @@ impl<'a> From<&'a Script> for Cow<'a, Script> {
/// Note: This will fail to compile on old Rust for targets that don't support atomics /// Note: This will fail to compile on old Rust for targets that don't support atomics
#[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))] #[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))]
#[cfg_attr(docsrs, doc(cfg(target_has_atomic = "ptr")))]
impl<'a> From<&'a Script> for Arc<Script> { impl<'a> From<&'a Script> for Arc<Script> {
fn from(value: &'a Script) -> Self { fn from(value: &'a Script) -> Self {
let rw: *const [u8] = Arc::into_raw(Arc::from(&value.0)); let rw: *const [u8] = Arc::into_raw(Arc::from(&value.0));
@ -446,7 +445,6 @@ impl PartialOrd<ScriptBuf> for Script {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl serde::Serialize for Script { impl serde::Serialize for Script {
/// User-facing serialization for `Script`. /// User-facing serialization for `Script`.
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@ -463,7 +461,6 @@ impl serde::Serialize for Script {
/// Can only deserialize borrowed bytes. /// Can only deserialize borrowed bytes.
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> serde::Deserialize<'de> for &'de Script { impl<'de> serde::Deserialize<'de> for &'de Script {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
@ -497,7 +494,6 @@ impl<'de> serde::Deserialize<'de> for &'de Script {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl serde::Serialize for ScriptBuf { impl serde::Serialize for ScriptBuf {
/// User-facing serialization for `Script`. /// User-facing serialization for `Script`.
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@ -509,7 +505,6 @@ impl serde::Serialize for ScriptBuf {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> serde::Deserialize<'de> for ScriptBuf { impl<'de> serde::Deserialize<'de> for ScriptBuf {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
@ -686,7 +681,6 @@ pub enum Error {
NumericOverflow, NumericOverflow,
/// Error validating the script with bitcoinconsensus library. /// Error validating the script with bitcoinconsensus library.
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
BitcoinConsensus(bitcoinconsensus::Error), BitcoinConsensus(bitcoinconsensus::Error),
/// Can not find the spent output. /// Can not find the spent output.
UnknownSpentOutput(OutPoint), UnknownSpentOutput(OutPoint),
@ -753,7 +747,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -122,7 +122,6 @@ impl fmt::Display for ParseOutPointError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for ParseOutPointError { impl std::error::Error for ParseOutPointError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::ParseOutPointError::*; use self::ParseOutPointError::*;
@ -943,7 +942,6 @@ impl Transaction {
/// Shorthand for [`Self::verify_with_flags`] with flag [`bitcoinconsensus::VERIFY_ALL`]. /// Shorthand for [`Self::verify_with_flags`] with flag [`bitcoinconsensus::VERIFY_ALL`].
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
pub fn verify<S>(&self, spent: S) -> Result<(), script::Error> pub fn verify<S>(&self, spent: S) -> Result<(), script::Error>
where where
S: FnMut(&OutPoint) -> Option<TxOut>, S: FnMut(&OutPoint) -> Option<TxOut>,
@ -955,7 +953,6 @@ impl Transaction {
/// ///
/// The `spent` closure should not return the same [`TxOut`] twice! /// The `spent` closure should not return the same [`TxOut`] twice!
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
pub fn verify_with_flags<S, F>(&self, mut spent: S, flags: F) -> Result<(), script::Error> pub fn verify_with_flags<S, F>(&self, mut spent: S, flags: F) -> Result<(), script::Error>
where where
S: FnMut(&OutPoint) -> Option<TxOut>, S: FnMut(&OutPoint) -> Option<TxOut>,

View File

@ -79,7 +79,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;
@ -733,7 +732,6 @@ impl<T: Encodable> Encodable for rc::Rc<T> {
/// Note: This will fail to compile on old Rust for targets that don't support atomics /// Note: This will fail to compile on old Rust for targets that don't support atomics
#[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))] #[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))]
#[cfg_attr(docsrs, doc(cfg(target_has_atomic = "ptr")))]
impl<T: Encodable> Encodable for sync::Arc<T> { impl<T: Encodable> Encodable for sync::Arc<T> {
fn consensus_encode<W: io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> { fn consensus_encode<W: io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
(**self).consensus_encode(w) (**self).consensus_encode(w)

View File

@ -15,5 +15,4 @@ pub use self::encode::{
pub use self::params::Params; pub use self::params::Params;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
pub mod serde; pub mod serde;

View File

@ -212,7 +212,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -51,7 +51,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;
@ -401,7 +400,6 @@ impl ops::Index<ops::RangeFull> for PrivateKey {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl serde::Serialize for PrivateKey { impl serde::Serialize for PrivateKey {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.collect_str(self) s.collect_str(self)
@ -409,7 +407,6 @@ impl serde::Serialize for PrivateKey {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> serde::Deserialize<'de> for PrivateKey { impl<'de> serde::Deserialize<'de> for PrivateKey {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PrivateKey, D::Error> { fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PrivateKey, D::Error> {
struct WifVisitor; struct WifVisitor;
@ -445,7 +442,6 @@ impl<'de> serde::Deserialize<'de> for PrivateKey {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
#[allow(clippy::collapsible_else_if)] // Aids readability. #[allow(clippy::collapsible_else_if)] // Aids readability.
impl serde::Serialize for PublicKey { impl serde::Serialize for PublicKey {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
@ -458,7 +454,6 @@ impl serde::Serialize for PublicKey {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> serde::Deserialize<'de> for PublicKey { impl<'de> serde::Deserialize<'de> for PublicKey {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error> { fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<PublicKey, D::Error> {
if d.is_human_readable() { if d.is_human_readable() {

View File

@ -268,7 +268,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use Error::*; use Error::*;

View File

@ -85,7 +85,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -31,7 +31,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;
@ -54,13 +53,11 @@ macro_rules! impl_std_error {
// No source available // No source available
($type:ty) => { ($type:ty) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for $type {} impl std::error::Error for $type {}
}; };
// Struct with $field as source // Struct with $field as source
($type:ty, $field:ident) => { ($type:ty, $field:ident) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for $type { impl std::error::Error for $type {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.$field) } fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.$field) }
} }

View File

@ -135,7 +135,6 @@ macro_rules! impl_bytes_newtype {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl $crate::serde::Serialize for $t { impl $crate::serde::Serialize for $t {
fn serialize<S: $crate::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { fn serialize<S: $crate::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
if s.is_human_readable() { if s.is_human_readable() {
@ -147,7 +146,6 @@ macro_rules! impl_bytes_newtype {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> $crate::serde::Deserialize<'de> for $t { impl<'de> $crate::serde::Deserialize<'de> for $t {
fn deserialize<D: $crate::serde::Deserializer<'de>>(d: D) -> Result<$t, D::Error> { fn deserialize<D: $crate::serde::Deserializer<'de>>(d: D) -> Result<$t, D::Error> {
if d.is_human_readable() { if d.is_human_readable() {

View File

@ -34,7 +34,7 @@
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)] #![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
// Experimental features we need. // Experimental features we need.
#![cfg_attr(bench, feature(test))] #![cfg_attr(bench, feature(test))]
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Coding conventions // Coding conventions
#![warn(missing_docs)] #![warn(missing_docs)]
// Instead of littering the codebase for non-fuzzing code just globally allow. // Instead of littering the codebase for non-fuzzing code just globally allow.
@ -57,12 +57,10 @@ extern crate test;
extern crate alloc; extern crate alloc;
#[cfg(feature = "base64")] #[cfg(feature = "base64")]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
pub extern crate base64; pub extern crate base64;
pub extern crate bech32; pub extern crate bech32;
pub extern crate bitcoin_hashes as hashes; pub extern crate bitcoin_hashes as hashes;
#[cfg(feature = "bitcoinconsensus")] #[cfg(feature = "bitcoinconsensus")]
#[cfg_attr(docsrs, doc(cfg(feature = "bitcoinconsensus")))]
pub extern crate bitcoinconsensus; pub extern crate bitcoinconsensus;
pub extern crate secp256k1; pub extern crate secp256k1;

View File

@ -504,7 +504,6 @@ impl fmt::Display for MerkleBlockError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for MerkleBlockError { impl std::error::Error for MerkleBlockError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::MerkleBlockError::*; use self::MerkleBlockError::*;

View File

@ -10,28 +10,20 @@
pub mod constants; pub mod constants;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod address; pub mod address;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub use self::address::Address; pub use self::address::Address;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod message; pub mod message;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod message_blockdata; pub mod message_blockdata;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod message_bloom; pub mod message_bloom;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod message_compact_blocks; pub mod message_compact_blocks;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod message_filter; pub mod message_filter;
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod message_network; pub mod message_network;
pub use self::constants::Magic; pub use self::constants::Magic;

View File

@ -91,7 +91,6 @@ impl Work {
/// used mainly for informative and displaying purposes, similarly to Bitcoin Core's /// used mainly for informative and displaying purposes, similarly to Bitcoin Core's
/// `log2_work` output in its logs. /// `log2_work` output in its logs.
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn log2(self) -> f64 { self.0.to_f64().log2() } pub fn log2(self) -> f64 { self.0.to_f64().log2() }
} }
do_impl!(Work); do_impl!(Work);
@ -702,7 +701,6 @@ impl fmt::Display for TryFromError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for TryFromError {} impl std::error::Error for TryFromError {}
impl Add for U256 { impl Add for U256 {
@ -785,7 +783,6 @@ impl_hex!(LowerHex, bitcoin_internals::hex::Case::Lower);
impl_hex!(UpperHex, bitcoin_internals::hex::Case::Upper); impl_hex!(UpperHex, bitcoin_internals::hex::Case::Upper);
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl crate::serde::Serialize for U256 { impl crate::serde::Serialize for U256 {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
@ -808,7 +805,6 @@ impl crate::serde::Serialize for U256 {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> crate::serde::Deserialize<'de> for U256 { impl<'de> crate::serde::Deserialize<'de> for U256 {
fn deserialize<D: crate::serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> { fn deserialize<D: crate::serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
use core::convert::TryInto; use core::convert::TryInto;

View File

@ -162,7 +162,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -601,7 +601,6 @@ impl fmt::Display for GetKeyError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for GetKeyError { impl std::error::Error for GetKeyError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use GetKeyError::*; use GetKeyError::*;
@ -722,7 +721,6 @@ impl fmt::Display for SignError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for SignError { impl std::error::Error for SignError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::SignError::*; use self::SignError::*;
@ -762,7 +760,6 @@ mod display_from_str {
/// Error encountered during PSBT decoding from Base64 string. /// Error encountered during PSBT decoding from Base64 string.
#[derive(Debug)] #[derive(Debug)]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
#[non_exhaustive] #[non_exhaustive]
pub enum PsbtParseError { pub enum PsbtParseError {
/// Error in internal PSBT data structure. /// Error in internal PSBT data structure.
@ -783,7 +780,6 @@ mod display_from_str {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for PsbtParseError { impl std::error::Error for PsbtParseError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::PsbtParseError::*; use self::PsbtParseError::*;
@ -795,14 +791,12 @@ mod display_from_str {
} }
} }
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
impl Display for PartiallySignedTransaction { impl Display for PartiallySignedTransaction {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", Base64Display::with_config(&self.serialize(), base64::STANDARD)) write!(f, "{}", Base64Display::with_config(&self.serialize(), base64::STANDARD))
} }
} }
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
impl FromStr for PartiallySignedTransaction { impl FromStr for PartiallySignedTransaction {
type Err = PsbtParseError; type Err = PsbtParseError;
@ -813,7 +807,6 @@ mod display_from_str {
} }
} }
#[cfg(feature = "base64")] #[cfg(feature = "base64")]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
pub use self::display_from_str::PsbtParseError; pub use self::display_from_str::PsbtParseError;
#[cfg(test)] #[cfg(test)]

View File

@ -10,7 +10,6 @@
use hashes::{sha256d, Hash, HashEngine}; use hashes::{sha256d, Hash, HashEngine};
#[cfg(feature = "secp-recovery")] #[cfg(feature = "secp-recovery")]
#[cfg_attr(docsrs, doc(cfg(feature = "secp-recovery")))]
pub use self::message_signing::{MessageSignature, MessageSignatureError}; pub use self::message_signing::{MessageSignature, MessageSignatureError};
use crate::consensus::{encode, Encodable}; use crate::consensus::{encode, Encodable};
@ -32,7 +31,6 @@ mod message_signing {
use crate::prelude::*; use crate::prelude::*;
/// An error used for dealing with Bitcoin Signed Messages. /// An error used for dealing with Bitcoin Signed Messages.
#[cfg_attr(docsrs, doc(cfg(feature = "secp-recovery")))]
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
#[non_exhaustive] #[non_exhaustive]
pub enum MessageSignatureError { pub enum MessageSignatureError {
@ -60,7 +58,6 @@ mod message_signing {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for MessageSignatureError { impl std::error::Error for MessageSignatureError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::MessageSignatureError::*; use self::MessageSignatureError::*;
@ -85,7 +82,6 @@ mod message_signing {
/// `fmt::Display` and `str::FromStr` implementations, the `base64` feature /// `fmt::Display` and `str::FromStr` implementations, the `base64` feature
/// must be enabled. /// must be enabled.
#[derive(Copy, Clone, PartialEq, Eq, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[cfg_attr(docsrs, doc(cfg(feature = "secp-recovery")))]
pub struct MessageSignature { pub struct MessageSignature {
/// The inner recoverable signature. /// The inner recoverable signature.
pub signature: RecoverableSignature, pub signature: RecoverableSignature,
@ -165,7 +161,6 @@ mod message_signing {
/// Convert a signature from base64 encoding. /// Convert a signature from base64 encoding.
#[cfg(feature = "base64")] #[cfg(feature = "base64")]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
pub fn from_base64(s: &str) -> Result<MessageSignature, MessageSignatureError> { pub fn from_base64(s: &str) -> Result<MessageSignature, MessageSignatureError> {
let bytes = base64::decode(s).map_err(|_| MessageSignatureError::InvalidBase64)?; let bytes = base64::decode(s).map_err(|_| MessageSignatureError::InvalidBase64)?;
MessageSignature::from_slice(&bytes) MessageSignature::from_slice(&bytes)
@ -173,12 +168,10 @@ mod message_signing {
/// Convert to base64 encoding. /// Convert to base64 encoding.
#[cfg(feature = "base64")] #[cfg(feature = "base64")]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
pub fn to_base64(self) -> String { base64::encode(&self.serialize()[..]) } pub fn to_base64(self) -> String { base64::encode(&self.serialize()[..]) }
} }
#[cfg(feature = "base64")] #[cfg(feature = "base64")]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
impl fmt::Display for MessageSignature { impl fmt::Display for MessageSignature {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let bytes = self.serialize(); let bytes = self.serialize();
@ -192,7 +185,6 @@ mod message_signing {
} }
#[cfg(feature = "base64")] #[cfg(feature = "base64")]
#[cfg_attr(docsrs, doc(cfg(feature = "base64")))]
impl core::str::FromStr for MessageSignature { impl core::str::FromStr for MessageSignature {
type Err = MessageSignatureError; type Err = MessageSignatureError;
fn from_str(s: &str) -> Result<MessageSignature, MessageSignatureError> { fn from_str(s: &str) -> Result<MessageSignature, MessageSignatureError> {

View File

@ -60,7 +60,6 @@ impl<E: fmt::Display> fmt::Display for FromHexError<E> {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl<E> std::error::Error for FromHexError<E> impl<E> std::error::Error for FromHexError<E>
where where
E: std::error::Error + 'static, E: std::error::Error + 'static,

View File

@ -612,7 +612,6 @@ impl core::fmt::Display for IncompleteBuilder {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for IncompleteBuilder { impl std::error::Error for IncompleteBuilder {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::IncompleteBuilder::*; use self::IncompleteBuilder::*;
@ -651,7 +650,6 @@ impl core::fmt::Display for HiddenNodes {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for HiddenNodes { impl std::error::Error for HiddenNodes {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::HiddenNodes::*; use self::HiddenNodes::*;
@ -851,7 +849,6 @@ impl TryFrom<TaprootBuilder> for NodeInfo {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl serde::Serialize for NodeInfo { impl serde::Serialize for NodeInfo {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
@ -868,7 +865,6 @@ impl serde::Serialize for NodeInfo {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> serde::Deserialize<'de> for NodeInfo { impl<'de> serde::Deserialize<'de> for NodeInfo {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
@ -1398,7 +1394,6 @@ impl fmt::UpperHex for LeafVersion {
/// Serializes [`LeafVersion`] as a `u8` using consensus encoding. /// Serializes [`LeafVersion`] as a `u8` using consensus encoding.
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl serde::Serialize for LeafVersion { impl serde::Serialize for LeafVersion {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
@ -1410,7 +1405,6 @@ impl serde::Serialize for LeafVersion {
/// Deserializes [`LeafVersion`] as a `u8` using consensus encoding. /// Deserializes [`LeafVersion`] as a `u8` using consensus encoding.
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de> serde::Deserialize<'de> for LeafVersion { impl<'de> serde::Deserialize<'de> for LeafVersion {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
@ -1492,7 +1486,6 @@ impl fmt::Display for TaprootBuilderError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for TaprootBuilderError { impl std::error::Error for TaprootBuilderError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::TaprootBuilderError::*; use self::TaprootBuilderError::*;
@ -1555,7 +1548,6 @@ impl fmt::Display for TaprootError {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for TaprootError { impl std::error::Error for TaprootError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::TaprootError::*; use self::TaprootError::*;

View File

@ -36,7 +36,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;

View File

@ -48,7 +48,6 @@ impl fmt::Display for Error {
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use self::Error::*;
@ -116,7 +115,6 @@ impl<'a> Iterator for HexIterator<'a> {
} }
#[cfg(any(feature = "std", feature = "core2"))] #[cfg(any(feature = "std", feature = "core2"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "core2"))))]
impl<'a> io::Read for HexIterator<'a> { impl<'a> io::Read for HexIterator<'a> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let mut bytes_read = 0usize; let mut bytes_read = 0usize;
@ -144,7 +142,6 @@ impl<'a> DoubleEndedIterator for HexIterator<'a> {
impl<'a> ExactSizeIterator for HexIterator<'a> {} impl<'a> ExactSizeIterator for HexIterator<'a> {}
#[cfg(any(test, feature = "std", feature = "alloc"))] #[cfg(any(test, feature = "std", feature = "alloc"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
impl FromHex for Vec<u8> { impl FromHex for Vec<u8> {
fn from_byte_iter<I>(iter: I) -> Result<Self, Error> fn from_byte_iter<I>(iter: I) -> Result<Self, Error>
where where

View File

@ -184,7 +184,6 @@ impl<T: Hash> Hash for Hmac<T> {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<T: Hash + Serialize> Serialize for Hmac<T> { impl<T: Hash + Serialize> Serialize for Hmac<T> {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> { fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
Serialize::serialize(&self.0, s) Serialize::serialize(&self.0, s)
@ -192,7 +191,6 @@ impl<T: Hash + Serialize> Serialize for Hmac<T> {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
impl<'de, T: Hash + Deserialize<'de>> Deserialize<'de> for Hmac<T> { impl<'de, T: Hash + Deserialize<'de>> Deserialize<'de> for Hmac<T> {
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Hmac<T>, D::Error> { fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Hmac<T>, D::Error> {
let bytes = Deserialize::deserialize(d)?; let bytes = Deserialize::deserialize(d)?;

View File

@ -80,7 +80,7 @@
// Coding conventions // Coding conventions
#![warn(missing_docs)] #![warn(missing_docs)]
// Experimental features we need. // Experimental features we need.
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(bench, feature(test))] #![cfg_attr(bench, feature(test))]
// In general, rust is absolutely horrid at supporting users doing things like, // In general, rust is absolutely horrid at supporting users doing things like,
// for example, compiling Rust code for real environments. Disable useless lints // for example, compiling Rust code for real environments. Disable useless lints

View File

@ -17,7 +17,6 @@
/// Functions used by serde impls of all hashes. /// Functions used by serde impls of all hashes.
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
pub mod serde_details { pub mod serde_details {
use core::marker::PhantomData; use core::marker::PhantomData;
use core::str::FromStr; use core::str::FromStr;
@ -121,7 +120,6 @@ pub mod serde_details {
/// represents a newtype over a byte-slice over length `$len`. /// represents a newtype over a byte-slice over length `$len`.
#[macro_export] #[macro_export]
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
macro_rules! serde_impl( macro_rules! serde_impl(
($t:ident, $len:expr $(, $gen:ident: $gent:ident)*) => ( ($t:ident, $len:expr $(, $gen:ident: $gent:ident)*) => (
impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> { impl<$($gen: $gent),*> $crate::serde_macros::serde_details::SerdeHash for $t<$($gen),*> {

View File

@ -399,7 +399,6 @@ macro_rules! hash_newtype_known_attrs {
} }
#[cfg(feature = "schemars")] #[cfg(feature = "schemars")]
#[cfg_attr(docsrs, doc(cfg(feature = "schemars")))]
pub mod json_hex_string { pub mod json_hex_string {
use schemars::gen::SchemaGenerator; use schemars::gen::SchemaGenerator;
use schemars::schema::{Schema, SchemaObject}; use schemars::schema::{Schema, SchemaObject};

View File

@ -35,7 +35,6 @@ pub trait DisplayHex: Copy + sealed::IsRef {
/// ///
/// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`. /// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`.
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
fn to_lower_hex_string(self) -> String { self.to_hex_string(Case::Lower) } fn to_lower_hex_string(self) -> String { self.to_hex_string(Case::Lower) }
/// Create an upper-hex-encoded string. /// Create an upper-hex-encoded string.
@ -44,14 +43,12 @@ pub trait DisplayHex: Copy + sealed::IsRef {
/// ///
/// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`. /// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`.
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
fn to_upper_hex_string(self) -> String { self.to_hex_string(Case::Upper) } fn to_upper_hex_string(self) -> String { self.to_hex_string(Case::Upper) }
/// Create a hex-encoded string. /// Create a hex-encoded string.
/// ///
/// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`. /// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`.
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
fn to_hex_string(self, case: Case) -> String { fn to_hex_string(self, case: Case) -> String {
let mut string = String::new(); let mut string = String::new();
self.append_hex_to_string(case, &mut string); self.append_hex_to_string(case, &mut string);
@ -63,7 +60,6 @@ pub trait DisplayHex: Copy + sealed::IsRef {
/// This may be faster than `write!(string, "{:x}", self.display_hex())` because it uses /// This may be faster than `write!(string, "{:x}", self.display_hex())` because it uses
/// `reserve_sugggestion`. /// `reserve_sugggestion`.
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
fn append_hex_to_string(self, case: Case, string: &mut String) { fn append_hex_to_string(self, case: Case, string: &mut String) {
use fmt::Write; use fmt::Write;
@ -112,7 +108,6 @@ impl<'a> DisplayHex for &'a [u8] {
} }
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl<'a> DisplayHex for &'a alloc::vec::Vec<u8> { impl<'a> DisplayHex for &'a alloc::vec::Vec<u8> {
type Display = DisplayByteSlice<'a>; type Display = DisplayByteSlice<'a>;

View File

@ -9,7 +9,7 @@
#![no_std] #![no_std]
// Experimental features we need. // Experimental features we need.
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Coding conventions // Coding conventions
#![warn(missing_docs)] #![warn(missing_docs)]