Skip to content

Commit

Permalink
Move associated types to top of struct
Browse files Browse the repository at this point in the history
There is no obvious reason why the associated types for `MiniscriptKey`
are below the trait methods. Move them to the top.

Note, the diff shows moving functions not associated types - same thing.

Refactor only, no logic changes.
  • Loading branch information
tcharding committed Mar 28, 2024
1 parent bdddc39 commit 133569a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,6 @@ pub use crate::primitives::relative_locktime::{RelLockTime, RelLockTimeError};

/// Trait representing a key which can be converted to a hash type.
pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Hash {
/// Returns true if the key is serialized uncompressed.
fn is_uncompressed(&self) -> bool;

/// Returns true if the key is an x-only pubkey.
fn is_x_only_key(&self) -> bool;

/// Returns the number of different derivation paths in this key.
///
/// Only >1 for keys in BIP389 multipath descriptors.
fn num_der_paths(&self) -> usize;

/// The type used in the sha256 fragment.
type Sha256: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;

Expand All @@ -177,6 +166,17 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha

/// The type used in the hash160 fragment.
type Hash160: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;

/// Returns true if the key is serialized uncompressed.
fn is_uncompressed(&self) -> bool;

/// Returns true if the key is an x-only pubkey.
fn is_x_only_key(&self) -> bool;

/// Returns the number of different derivation paths in this key.
///
/// Only >1 for keys in BIP389 multipath descriptors.
fn num_der_paths(&self) -> usize;
}

impl MiniscriptKey for bitcoin::secp256k1::PublicKey {
Expand Down

0 comments on commit 133569a

Please sign in to comment.