Skip to content

Commit b56f446

Browse files
committed
Move associated types to top of struct
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.
1 parent b7a559d commit b56f446

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,6 @@ pub use crate::primitives::threshold::{Threshold, ThresholdError};
149149

150150
/// Trait representing a key which can be converted to a hash type.
151151
pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Hash {
152-
/// Returns true if the key is serialized uncompressed (defaults to `false`).
153-
fn is_uncompressed(&self) -> bool;
154-
155-
/// Returns true if the key is an x-only pubkey (defaults to `false`).
156-
fn is_x_only_key(&self) -> bool;
157-
158-
/// Returns the number of different derivation paths in this key (defaults to `0`).
159-
///
160-
/// Only >1 for keys in BIP389 multipath descriptors.
161-
fn num_der_paths(&self) -> usize;
162-
163-
/// The associated `sha256::Hash` for this `MiniscriptKey`, used in the sha256 fragment.
164152
type Sha256: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;
165153

166154
/// The associated `hash256::Hash` for this `MiniscriptKey`, used in the hash256 fragment.
@@ -171,6 +159,17 @@ pub trait MiniscriptKey: Clone + Eq + Ord + fmt::Debug + fmt::Display + hash::Ha
171159

172160
/// The associated `hash160::Hash` for this `MiniscriptKey` type, used in the hash160 fragment.
173161
type Hash160: Clone + Eq + Ord + fmt::Display + fmt::Debug + hash::Hash;
162+
163+
/// Returns true if the key is serialized uncompressed (defaults to `false`).
164+
fn is_uncompressed(&self) -> bool;
165+
166+
/// Returns true if the key is an x-only pubkey (defaults to `false`).
167+
fn is_x_only_key(&self) -> bool;
168+
169+
/// Returns the number of different derivation paths in this key (defaults to `0`).
170+
///
171+
/// Only >1 for keys in BIP389 multipath descriptors.
172+
fn num_der_paths(&self) -> usize;
174173
}
175174

176175
impl MiniscriptKey for bitcoin::secp256k1::PublicKey {

0 commit comments

Comments
 (0)