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:
parent
e7efdd7c42
commit
adaf4ac086
|
@ -605,8 +605,8 @@ impl Xpriv {
|
|||
}
|
||||
|
||||
/// Constructs a new extended public key from this extended private key.
|
||||
pub fn to_xpub<C: secp256k1::Signing>(&self, secp: &Secp256k1<C>) -> Xpub {
|
||||
Xpub::from_xpriv(secp, self)
|
||||
pub fn to_xpub<C: secp256k1::Signing>(self, secp: &Secp256k1<C>) -> Xpub {
|
||||
Xpub::from_xpriv(secp, &self)
|
||||
}
|
||||
|
||||
/// Constructs a new BIP340 keypair for Schnorr signatures and Taproot use matching the internal
|
||||
|
|
|
@ -327,7 +327,7 @@ impl CompressedPublicKey {
|
|||
///
|
||||
/// 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.
|
||||
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.
|
||||
pub fn from_slice(data: &[u8]) -> Result<Self, secp256k1::Error> {
|
||||
|
|
|
@ -1401,6 +1401,7 @@ impl<E> EncodeSigningDataResult<E> {
|
|||
/// // 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> {
|
||||
match self {
|
||||
EncodeSigningDataResult::SighashSingleBug => Ok(true),
|
||||
|
|
|
@ -303,7 +303,7 @@ macro_rules! impl_array_newtype {
|
|||
|
||||
/// Copies the underlying bytes into a new `Vec`.
|
||||
#[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.
|
||||
#[inline]
|
||||
|
@ -312,7 +312,7 @@ macro_rules! impl_array_newtype {
|
|||
/// Copies the underlying bytes into a new `Vec`.
|
||||
#[inline]
|
||||
#[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.
|
||||
#[inline]
|
||||
|
|
|
@ -155,8 +155,8 @@ impl SerializedSignature {
|
|||
/// Convert the serialized signature into the Signature struct.
|
||||
/// (This deserializes it)
|
||||
#[inline]
|
||||
pub fn to_signature(&self) -> Result<Signature, SigFromSliceError> {
|
||||
Signature::from_slice(self)
|
||||
pub fn to_signature(self) -> Result<Signature, SigFromSliceError> {
|
||||
Signature::from_slice(&self)
|
||||
}
|
||||
|
||||
/// Constructs a new SerializedSignature from a Signature.
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
msrv = "1.63.0"
|
||||
too-many-arguments-threshold = 13
|
||||
avoid-breaking-exported-api = false
|
||||
|
|
|
@ -81,7 +81,7 @@ impl LockTime {
|
|||
/// Locktimes are not ordered by the natural ordering on `u32`. If you want to
|
||||
/// compare locktimes, use [`Self::is_implied_by`] or similar methods.
|
||||
#[inline]
|
||||
pub fn to_consensus_u32(&self) -> u32 {
|
||||
pub fn to_consensus_u32(self) -> u32 {
|
||||
match self {
|
||||
LockTime::Blocks(ref h) => h.to_consensus_u32(),
|
||||
LockTime::Time(ref t) => t.to_consensus_u32(),
|
||||
|
@ -99,7 +99,7 @@ impl LockTime {
|
|||
|
||||
/// Encodes the locktime as a sequence number.
|
||||
#[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.
|
||||
#[inline]
|
||||
|
|
|
@ -184,7 +184,7 @@ impl Sequence {
|
|||
|
||||
/// Constructs a new [`relative::LockTime`] from this [`Sequence`] number.
|
||||
#[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};
|
||||
|
||||
if !self.is_relative_lock_time() {
|
||||
|
|
|
@ -47,7 +47,7 @@ impl BlockHeight {
|
|||
|
||||
/// Returns block height as a `u32`.
|
||||
// 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 {
|
||||
|
@ -114,7 +114,7 @@ impl BlockInterval {
|
|||
|
||||
/// Returns block interval as a `u32`.
|
||||
// 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 {
|
||||
|
|
|
@ -33,7 +33,7 @@ impl Height {
|
|||
/// Returns the `u32` value used to encode this locktime in an nSequence field or
|
||||
/// argument to `OP_CHECKSEQUENCEVERIFY`.
|
||||
#[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
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ impl Time {
|
|||
/// Returns the `u32` value used to encode this locktime in an nSequence field or
|
||||
/// argument to `OP_CHECKSEQUENCEVERIFY`.
|
||||
#[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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue