Skip to content

Commit a1cf394

Browse files
committed
Use struct field shorthand
Clippy emits: warning: redundant field names in struct initialization As suggested, use the field init shorthand.
1 parent e94bf6e commit a1cf394

File tree

7 files changed

+19
-22
lines changed

7 files changed

+19
-22
lines changed

src/descriptor/bare.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
4949
pub fn new(ms: Miniscript<Pk, BareCtx>) -> Result<Self, Error> {
5050
// do the top-level checks
5151
BareCtx::top_level_checks(&ms)?;
52-
Ok(Self { ms: ms })
52+
Ok(Self { ms })
5353
}
5454

5555
/// get the inner
@@ -241,7 +241,7 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
241241
/// Create a new Pkh descriptor
242242
pub fn new(pk: Pk) -> Self {
243243
// do the top-level checks
244-
Self { pk: pk }
244+
Self { pk }
245245
}
246246

247247
/// Get a reference to the inner key

src/descriptor/segwitv0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ where
313313
WshInner::SortedMulti(ref smv) => WshInner::SortedMulti(smv.translate_pk(&mut fpk)?),
314314
WshInner::Ms(ref ms) => WshInner::Ms(ms.translate_pk(&mut fpk, &mut fpkh)?),
315315
};
316-
Ok(Wsh { inner: inner })
316+
Ok(Wsh { inner })
317317
}
318318
}
319319

@@ -333,7 +333,7 @@ impl<Pk: MiniscriptKey> Wpkh<Pk> {
333333
pk.to_string(),
334334
)))
335335
} else {
336-
Ok(Self { pk: pk })
336+
Ok(Self { pk })
337337
}
338338
}
339339

src/descriptor/sh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ where
112112
ShInner::Ms(sub)
113113
}
114114
};
115-
Ok(Sh { inner: inner })
115+
Ok(Sh { inner })
116116
} else {
117117
Err(Error::Unexpected(format!(
118118
"{}({} args) while parsing sh descriptor",
@@ -439,6 +439,6 @@ where
439439
ShInner::SortedMulti(ref smv) => ShInner::SortedMulti(smv.translate_pk(&mut fpk)?),
440440
ShInner::Ms(ref ms) => ShInner::Ms(ms.translate_pk(&mut fpk, &mut fpkh)?),
441441
};
442-
Ok(Sh { inner: inner })
442+
Ok(Sh { inner })
443443
}
444444
}

src/interpreter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'txin> Interpreter<'txin> {
192192
verify_sig: Box<dyn FnMut(&KeySigPair) -> bool + 'iter>,
193193
) -> Iter<'txin, 'iter> {
194194
Iter {
195-
verify_sig: verify_sig,
195+
verify_sig,
196196
public_key: if let inner::Inner::PublicKey(ref pk, _) = self.inner {
197197
Some(pk)
198198
} else {

src/interpreter/stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl<'txin> Stack<'txin> {
209209
self.push(Element::Satisfied);
210210
Some(Ok(SatisfiedConstraint::PublicKeyHash {
211211
keyhash: pkh.hash160(),
212-
key_sig: key_sig,
212+
key_sig,
213213
}))
214214
}
215215
Err(e) => return Some(Err(e)),

src/miniscript/decode.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> TerminalStack<Pk, Ctx> {
224224
let ext = ExtData::type_check(&ms, return_none)?;
225225
let ms = Miniscript {
226226
node: ms,
227-
ty: ty,
228-
ext: ext,
227+
ty,
228+
ext,
229229
phantom: PhantomData,
230230
};
231231
Ctx::check_global_validity(&ms)?;
@@ -245,8 +245,8 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> TerminalStack<Pk, Ctx> {
245245
let ext = ExtData::type_check(&wrapped_ms, return_none)?;
246246
let ms = Miniscript {
247247
node: wrapped_ms,
248-
ty: ty,
249-
ext: ext,
248+
ty,
249+
ext,
250250
phantom: PhantomData,
251251
};
252252
Ctx::check_global_validity(&ms)?;
@@ -268,8 +268,8 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> TerminalStack<Pk, Ctx> {
268268
let ext = ExtData::type_check(&wrapped_ms, return_none)?;
269269
let ms = Miniscript {
270270
node: wrapped_ms,
271-
ty: ty,
272-
ext: ext,
271+
ty,
272+
ext,
273273
phantom: PhantomData,
274274
};
275275
Ctx::check_global_validity(&ms)?;
@@ -558,8 +558,8 @@ pub fn parse<Ctx: ScriptContext>(
558558

559559
term.0.push(Miniscript {
560560
node: wrapped_ms,
561-
ty: ty,
562-
ext: ext,
561+
ty,
562+
ext,
563563
phantom: PhantomData,
564564
});
565565
}

src/psbt/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,7 @@ impl<'psbt> PsbtInputSatisfier<'psbt> {
249249
/// create a new PsbtInputsatisfier from
250250
/// psbt and index
251251
pub fn new(psbt: &'psbt Psbt, index: usize) -> Self {
252-
Self {
253-
psbt: psbt,
254-
index: index,
255-
}
252+
Self { psbt, index }
256253
}
257254
}
258255

@@ -639,7 +636,7 @@ impl PsbtExt for Psbt {
639636
if index >= self.inputs.len() {
640637
return Err(Error::InputIdxOutofBounds {
641638
psbt_inp: self.inputs.len(),
642-
index: index,
639+
index,
643640
});
644641
}
645642
finalizer::finalize_input(self, index, secp, /*allow_mall*/ false)
@@ -664,7 +661,7 @@ impl PsbtExt for Psbt {
664661
if index >= self.inputs.len() {
665662
return Err(Error::InputIdxOutofBounds {
666663
psbt_inp: self.inputs.len(),
667-
index: index,
664+
index,
668665
});
669666
}
670667
finalizer::finalize_input(self, index, secp, /*allow_mall*/ false)

0 commit comments

Comments
 (0)