Skip to content

Commit

Permalink
Take advantage of shorter generic Key
Browse files Browse the repository at this point in the history
Now we have `Key` instead of `MiniscriptKey` we can take advantage of
the shorter name to inline the where clauses when appropriate.
  • Loading branch information
tcharding committed Jul 25, 2023
1 parent 43e2424 commit d2510bc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 40 deletions.
12 changes: 2 additions & 10 deletions src/descriptor/bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,7 @@ impl<Pk: Key> ForEachKey<Pk> for Bare<Pk> {
}
}

impl<P, Q> TranslatePk<P, Q> for Bare<P>
where
P: Key,
Q: Key,
{
impl<P: Key, Q: Key> TranslatePk<P, Q> for Bare<P> {
type Output = Bare<Q>;

fn translate_pk<T, E>(&self, t: &mut T) -> Result<Bare<Q>, TranslateErr<E>>
Expand Down Expand Up @@ -366,11 +362,7 @@ impl<Pk: Key> ForEachKey<Pk> for Pkh<Pk> {
}
}

impl<P, Q> TranslatePk<P, Q> for Pkh<P>
where
P: Key,
Q: Key,
{
impl<P: Key, Q: Key> TranslatePk<P, Q> for Pkh<P> {
type Output = Pkh<Q>;

fn translate_pk<T, E>(&self, t: &mut T) -> Result<Self::Output, TranslateErr<E>>
Expand Down
6 changes: 1 addition & 5 deletions src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,7 @@ impl<Pk: Key + ToPublicKey> Descriptor<Pk> {
}
}

impl<P, Q> TranslatePk<P, Q> for Descriptor<P>
where
P: Key,
Q: Key,
{
impl<P: Key, Q: Key> TranslatePk<P, Q> for Descriptor<P> {
type Output = Descriptor<Q>;

/// Converts a descriptor using abstract keys to one using specific keys.
Expand Down
12 changes: 2 additions & 10 deletions src/descriptor/segwitv0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,7 @@ impl<Pk: Key> ForEachKey<Pk> for Wsh<Pk> {
}
}

impl<P, Q> TranslatePk<P, Q> for Wsh<P>
where
P: Key,
Q: Key,
{
impl<P: Key, Q: Key> TranslatePk<P, Q> for Wsh<P> {
type Output = Wsh<Q>;

fn translate_pk<T, E>(&self, t: &mut T) -> Result<Self::Output, TranslateErr<E>>
Expand Down Expand Up @@ -473,11 +469,7 @@ impl<Pk: Key> ForEachKey<Pk> for Wpkh<Pk> {
}
}

impl<P, Q> TranslatePk<P, Q> for Wpkh<P>
where
P: Key,
Q: Key,
{
impl<P: Key, Q: Key> TranslatePk<P, Q> for Wpkh<P> {
type Output = Wpkh<Q>;

fn translate_pk<T, E>(&self, t: &mut T) -> Result<Self::Output, TranslateErr<E>>
Expand Down
6 changes: 1 addition & 5 deletions src/descriptor/sh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,7 @@ impl<Pk: Key> ForEachKey<Pk> for Sh<Pk> {
}
}

impl<P, Q> TranslatePk<P, Q> for Sh<P>
where
P: Key,
Q: Key,
{
impl<P: Key, Q: Key> TranslatePk<P, Q> for Sh<P> {
type Output = Sh<Q>;

fn translate_pk<T, E>(&self, t: &mut T) -> Result<Self::Output, TranslateErr<E>>
Expand Down
6 changes: 1 addition & 5 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,7 @@ impl<Pk: Key> ForEachKey<Pk> for Tr<Pk> {
}
}

impl<P, Q> TranslatePk<P, Q> for Tr<P>
where
P: Key,
Q: Key,
{
impl<P: Key, Q: Key> TranslatePk<P, Q> for Tr<P> {
type Output = Tr<Q>;

fn translate_pk<T, E>(&self, translate: &mut T) -> Result<Self::Output, TranslateErr<E>>
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,7 @@ impl<E: fmt::Debug> fmt::Debug for TranslateErr<E> {

/// Converts a descriptor using abstract keys to one using specific keys. Uses translator `t` to do
/// the actual translation function calls.
pub trait TranslatePk<P, Q>
where
P: Key,
Q: Key,
{
pub trait TranslatePk<P: Key, Q: Key> {
/// The associated output type. This must be `Self<Q>`.
type Output;

Expand Down

0 comments on commit d2510bc

Please sign in to comment.