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.
  • Loading branch information
tcharding committed Oct 17, 2023
1 parent 7270edf commit 063b255
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 @@ -150,17 +150,6 @@ use crate::prelude::*;

/// 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, defaults to `false`.
fn is_uncompressed(&self) -> bool;

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

/// Returns the number of different derivation paths in this key, defaults to `0`.
///
/// 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 @@ -172,6 +161,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, defaults to `false`.
fn is_uncompressed(&self) -> bool;

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

/// Returns the number of different derivation paths in this key, defaults to `0`.
///
/// 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 063b255

Please sign in to comment.