Skip to content

Commit a6340fe

Browse files
committed
remove a bunch of unnecessary where clauses
The compiler seems to need a `where Pk:'a` clause on the ForEachKey trait definition, but not on any of the impls. Since this clause costs us two LOC per impl and doesn't have much value for the reader of the code, just drop it.
1 parent 663bc00 commit a6340fe

File tree

10 files changed

+14
-56
lines changed

10 files changed

+14
-56
lines changed

src/descriptor/bare.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,7 @@ impl_from_str!(
176176
);
177177

178178
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Bare<Pk> {
179-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool
180-
where
181-
Pk: 'a,
182-
{
179+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool {
183180
self.ms.for_each_key(pred)
184181
}
185182
}
@@ -361,10 +358,7 @@ impl_from_str!(
361358
);
362359

363360
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Pkh<Pk> {
364-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
365-
where
366-
Pk: 'a,
367-
{
361+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
368362
pred(&self.pk)
369363
}
370364
}

src/descriptor/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,7 @@ where
536536
}
537537

538538
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Descriptor<Pk> {
539-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool
540-
where
541-
Pk: 'a,
542-
{
539+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool {
543540
match *self {
544541
Descriptor::Bare(ref bare) => bare.for_each_key(pred),
545542
Descriptor::Pkh(ref pkh) => pkh.for_each_key(pred),

src/descriptor/segwitv0.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,7 @@ impl_from_str!(
267267
);
268268

269269
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Wsh<Pk> {
270-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool
271-
where
272-
Pk: 'a,
273-
{
270+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool {
274271
match self.inner {
275272
WshInner::SortedMulti(ref smv) => smv.for_each_key(pred),
276273
WshInner::Ms(ref ms) => ms.for_each_key(pred),
@@ -474,10 +471,7 @@ impl_from_str!(
474471
);
475472

476473
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Wpkh<Pk> {
477-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
478-
where
479-
Pk: 'a,
480-
{
474+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
481475
pred(&self.pk)
482476
}
483477
}

src/descriptor/sh.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Sh<Pk> {
420420
}
421421

422422
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Sh<Pk> {
423-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool
424-
where
425-
Pk: 'a,
426-
{
423+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool {
427424
match self.inner {
428425
ShInner::Wsh(ref wsh) => wsh.for_each_key(pred),
429426
ShInner::SortedMulti(ref smv) => smv.for_each_key(pred),

src/descriptor/sortedmulti.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> SortedMultiVec<Pk, Ctx> {
102102
}
103103

104104
impl<Pk: MiniscriptKey, Ctx: ScriptContext> ForEachKey<Pk> for SortedMultiVec<Pk, Ctx> {
105-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool
106-
where
107-
Pk: 'a,
108-
{
105+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool {
109106
self.pks.iter().all(pred)
110107
}
111108
}

src/descriptor/tr.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,7 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for Tr<Pk> {
612612
}
613613

614614
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Tr<Pk> {
615-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
616-
where
617-
Pk: 'a,
618-
{
615+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
619616
let script_keys_res = self
620617
.iter_scripts()
621618
.all(|(_d, ms)| ms.for_each_key(&mut pred));

src/miniscript/astelem.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ where
6464
}
6565

6666
impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
67-
pub(super) fn real_for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: &mut F) -> bool
68-
where
69-
Pk: 'a,
70-
{
67+
pub(super) fn real_for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: &mut F) -> bool {
7168
match *self {
7269
Terminal::PkK(ref p) => pred(p),
7370
Terminal::PkH(ref p) => pred(p),
@@ -182,10 +179,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
182179
}
183180

184181
impl<Pk: MiniscriptKey, Ctx: ScriptContext> ForEachKey<Pk> for Terminal<Pk, Ctx> {
185-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
186-
where
187-
Pk: 'a,
188-
{
182+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
189183
self.real_for_each_key(&mut pred)
190184
}
191185
}

src/miniscript/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
273273
}
274274

275275
impl<Pk: MiniscriptKey, Ctx: ScriptContext> ForEachKey<Pk> for Miniscript<Pk, Ctx> {
276-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
277-
where
278-
Pk: 'a,
279-
{
276+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
280277
self.real_for_each_key(&mut pred)
281278
}
282279
}
@@ -300,10 +297,7 @@ where
300297
}
301298

302299
impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
303-
fn real_for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: &mut F) -> bool
304-
where
305-
Pk: 'a,
306-
{
300+
fn real_for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: &mut F) -> bool {
307301
self.node.real_for_each_key(pred)
308302
}
309303

src/policy/concrete.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,7 @@ impl<Pk: MiniscriptKey> PolicyArc<Pk> {
664664
}
665665

666666
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Policy<Pk> {
667-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
668-
where
669-
Pk: 'a,
670-
{
667+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
671668
self.real_for_each_key(&mut pred)
672669
}
673670
}

src/policy/semantic.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ where
6161
}
6262

6363
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Policy<Pk> {
64-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool
65-
where
66-
Pk: 'a,
67-
{
64+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
6865
self.real_for_each_key(&mut pred)
6966
}
7067
}

0 commit comments

Comments
 (0)