Set avoid-breaking-exported-api to false

These lints are valuable, lets get at em.

Changes are API breaking but because the changes make functions consume
self for types that are `Copy` downstream should not notice the breaks.
This commit is contained in:
Tobin C. Harding 2024-12-11 09:59:40 +11:00
parent e7efdd7c42
commit adaf4ac086
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
10 changed files with 16 additions and 14 deletions

View File

@ -605,8 +605,8 @@ impl Xpriv {
} }
/// Constructs a new extended public key from this extended private key. /// Constructs a new extended public key from this extended private key.
pub fn to_xpub<C: secp256k1::Signing>(&self, secp: &Secp256k1<C>) -> Xpub { pub fn to_xpub<C: secp256k1::Signing>(self, secp: &Secp256k1<C>) -> Xpub {
Xpub::from_xpriv(secp, self) Xpub::from_xpriv(secp, &self)
} }
/// Constructs a new BIP340 keypair for Schnorr signatures and Taproot use matching the internal /// Constructs a new BIP340 keypair for Schnorr signatures and Taproot use matching the internal

View File

@ -327,7 +327,7 @@ impl CompressedPublicKey {
/// ///
/// Note that this can be used as a sort key to get BIP67-compliant sorting. /// Note that this can be used as a sort key to get BIP67-compliant sorting.
/// That's why this type doesn't have the `to_sort_key` method - it would duplicate this one. /// That's why this type doesn't have the `to_sort_key` method - it would duplicate this one.
pub fn to_bytes(&self) -> [u8; 33] { self.0.serialize() } pub fn to_bytes(self) -> [u8; 33] { self.0.serialize() }
/// Deserializes a public key from a slice. /// Deserializes a public key from a slice.
pub fn from_slice(data: &[u8]) -> Result<Self, secp256k1::Error> { pub fn from_slice(data: &[u8]) -> Result<Self, secp256k1::Error> {

View File

@ -1401,6 +1401,7 @@ impl<E> EncodeSigningDataResult<E> {
/// // use the hash from `writer` /// // use the hash from `writer`
/// } /// }
/// ``` /// ```
#[allow(clippy::wrong_self_convention)] // Consume self so we can take the error.
pub fn is_sighash_single_bug(self) -> Result<bool, E> { pub fn is_sighash_single_bug(self) -> Result<bool, E> {
match self { match self {
EncodeSigningDataResult::SighashSingleBug => Ok(true), EncodeSigningDataResult::SighashSingleBug => Ok(true),

View File

@ -303,7 +303,7 @@ macro_rules! impl_array_newtype {
/// Copies the underlying bytes into a new `Vec`. /// Copies the underlying bytes into a new `Vec`.
#[inline] #[inline]
pub fn to_vec(&self) -> alloc::vec::Vec<u8> { self.0.to_vec() } pub fn to_vec(self) -> alloc::vec::Vec<u8> { self.0.to_vec() }
/// Returns a slice of the underlying bytes. /// Returns a slice of the underlying bytes.
#[inline] #[inline]
@ -312,7 +312,7 @@ macro_rules! impl_array_newtype {
/// Copies the underlying bytes into a new `Vec`. /// Copies the underlying bytes into a new `Vec`.
#[inline] #[inline]
#[deprecated(since = "TBD", note = "use to_vec instead")] #[deprecated(since = "TBD", note = "use to_vec instead")]
pub fn to_bytes(&self) -> alloc::vec::Vec<u8> { self.to_vec() } pub fn to_bytes(self) -> alloc::vec::Vec<u8> { self.to_vec() }
/// Converts the object to a raw pointer. /// Converts the object to a raw pointer.
#[inline] #[inline]

View File

@ -155,8 +155,8 @@ impl SerializedSignature {
/// Convert the serialized signature into the Signature struct. /// Convert the serialized signature into the Signature struct.
/// (This deserializes it) /// (This deserializes it)
#[inline] #[inline]
pub fn to_signature(&self) -> Result<Signature, SigFromSliceError> { pub fn to_signature(self) -> Result<Signature, SigFromSliceError> {
Signature::from_slice(self) Signature::from_slice(&self)
} }
/// Constructs a new SerializedSignature from a Signature. /// Constructs a new SerializedSignature from a Signature.

View File

@ -1,2 +1,3 @@
msrv = "1.63.0" msrv = "1.63.0"
too-many-arguments-threshold = 13 too-many-arguments-threshold = 13
avoid-breaking-exported-api = false

View File

@ -81,7 +81,7 @@ impl LockTime {
/// Locktimes are not ordered by the natural ordering on `u32`. If you want to /// Locktimes are not ordered by the natural ordering on `u32`. If you want to
/// compare locktimes, use [`Self::is_implied_by`] or similar methods. /// compare locktimes, use [`Self::is_implied_by`] or similar methods.
#[inline] #[inline]
pub fn to_consensus_u32(&self) -> u32 { pub fn to_consensus_u32(self) -> u32 {
match self { match self {
LockTime::Blocks(ref h) => h.to_consensus_u32(), LockTime::Blocks(ref h) => h.to_consensus_u32(),
LockTime::Time(ref t) => t.to_consensus_u32(), LockTime::Time(ref t) => t.to_consensus_u32(),
@ -99,7 +99,7 @@ impl LockTime {
/// Encodes the locktime as a sequence number. /// Encodes the locktime as a sequence number.
#[inline] #[inline]
pub fn to_sequence(&self) -> Sequence { Sequence::from_consensus(self.to_consensus_u32()) } pub fn to_sequence(self) -> Sequence { Sequence::from_consensus(self.to_consensus_u32()) }
/// Constructs a new `LockTime` from `n`, expecting `n` to be a 16-bit count of blocks. /// Constructs a new `LockTime` from `n`, expecting `n` to be a 16-bit count of blocks.
#[inline] #[inline]

View File

@ -184,7 +184,7 @@ impl Sequence {
/// Constructs a new [`relative::LockTime`] from this [`Sequence`] number. /// Constructs a new [`relative::LockTime`] from this [`Sequence`] number.
#[inline] #[inline]
pub fn to_relative_lock_time(&self) -> Option<relative::LockTime> { pub fn to_relative_lock_time(self) -> Option<relative::LockTime> {
use crate::locktime::relative::{Height, LockTime, Time}; use crate::locktime::relative::{Height, LockTime, Time};
if !self.is_relative_lock_time() { if !self.is_relative_lock_time() {

View File

@ -47,7 +47,7 @@ impl BlockHeight {
/// Returns block height as a `u32`. /// Returns block height as a `u32`.
// Because type inference doesn't always work using `Into`. // Because type inference doesn't always work using `Into`.
pub const fn to_u32(&self) -> u32 { self.0 } pub const fn to_u32(self) -> u32 { self.0 }
} }
impl fmt::Display for BlockHeight { impl fmt::Display for BlockHeight {
@ -114,7 +114,7 @@ impl BlockInterval {
/// Returns block interval as a `u32`. /// Returns block interval as a `u32`.
// Because type inference doesn't always work using `Into`. // Because type inference doesn't always work using `Into`.
pub const fn to_u32(&self) -> u32 { self.0 } pub const fn to_u32(self) -> u32 { self.0 }
} }
impl fmt::Display for BlockInterval { impl fmt::Display for BlockInterval {

View File

@ -33,7 +33,7 @@ impl Height {
/// Returns the `u32` value used to encode this locktime in an nSequence field or /// Returns the `u32` value used to encode this locktime in an nSequence field or
/// argument to `OP_CHECKSEQUENCEVERIFY`. /// argument to `OP_CHECKSEQUENCEVERIFY`.
#[inline] #[inline]
pub const fn to_consensus_u32(&self) -> u32 { pub const fn to_consensus_u32(self) -> u32 {
self.0 as u32 // cast safety: u32 is wider than u16 on all architectures self.0 as u32 // cast safety: u32 is wider than u16 on all architectures
} }
} }
@ -113,7 +113,7 @@ impl Time {
/// Returns the `u32` value used to encode this locktime in an nSequence field or /// Returns the `u32` value used to encode this locktime in an nSequence field or
/// argument to `OP_CHECKSEQUENCEVERIFY`. /// argument to `OP_CHECKSEQUENCEVERIFY`.
#[inline] #[inline]
pub const fn to_consensus_u32(&self) -> u32 { pub const fn to_consensus_u32(self) -> u32 {
(1u32 << 22) | self.0 as u32 // cast safety: u32 is wider than u16 on all architectures (1u32 << 22) | self.0 as u32 // cast safety: u32 is wider than u16 on all architectures
} }
} }