Skip to content

Commit 372d5d6

Browse files
committed
clippy: fix return_self_not_must_use
I'm not convinced that any of these are really necessary, but they don't hurt and might save somebody a bug.
1 parent 35ee8f3 commit 372d5d6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/address.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ impl Address {
437437
}
438438

439439
/// Convert this address to an unconfidential address.
440+
#[must_use]
440441
pub fn to_unconfidential(&self) -> Address {
441442
Address {
442443
params: self.params,
@@ -446,6 +447,7 @@ impl Address {
446447
}
447448

448449
/// Convert this address to a confidential address with the given blinding pubkey.
450+
#[must_use]
449451
pub fn to_confidential(&self, blinding_pubkey: secp256k1_zkp::PublicKey) -> Address {
450452
Address {
451453
params: self.params,

src/script.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ impl Script {
331331
pub fn into_bytes(self) -> Vec<u8> { self.0.into_vec() }
332332

333333
/// Compute the P2SH output corresponding to this redeem script
334+
#[must_use]
334335
pub fn to_p2sh(&self) -> Script {
335336
Builder::new().push_opcode(opcodes::all::OP_HASH160)
336337
.push_slice(&ScriptHash::hash(&self.0)[..])
@@ -340,6 +341,7 @@ impl Script {
340341

341342
/// Compute the P2WSH output corresponding to this witnessScript (aka the "witness redeem
342343
/// script")
344+
#[must_use]
343345
pub fn to_v0_p2wsh(&self) -> Script {
344346
Builder::new().push_int(0)
345347
.push_slice(&WScriptHash::hash(&self.0)[..])
@@ -741,6 +743,7 @@ impl Builder {
741743
/// Adds instructions to push an integer onto the stack. Integers are
742744
/// encoded as little-endian signed-magnitude numbers, but there are
743745
/// dedicated opcodes to push some small integers.
746+
#[must_use]
744747
pub fn push_int(self, data: i64) -> Builder {
745748
// We can special-case -1, 1-16
746749
if data == -1 || (data >= 1 && data <= 16) {
@@ -759,11 +762,13 @@ impl Builder {
759762

760763
/// Adds instructions to push an integer onto the stack, using the explicit
761764
/// encoding regardless of the availability of dedicated opcodes.
765+
#[must_use]
762766
pub fn push_scriptint(self, data: i64) -> Builder {
763767
self.push_slice(&build_scriptint(data))
764768
}
765769

766770
/// Adds instructions to push some arbitrary data onto the stack
771+
#[must_use]
767772
pub fn push_slice(mut self, data: &[u8]) -> Builder {
768773
// Start with a PUSH opcode
769774
match data.len() as u64 {
@@ -793,6 +798,7 @@ impl Builder {
793798
}
794799

795800
/// Pushes a public key
801+
#[must_use]
796802
pub fn push_key(self, key: &PublicKey) -> Builder {
797803
if key.compressed {
798804
self.push_slice(&key.inner.serialize()[..])
@@ -802,6 +808,7 @@ impl Builder {
802808
}
803809

804810
/// Adds a single opcode to the script
811+
#[must_use]
805812
pub fn push_opcode(mut self, data: opcodes::All) -> Builder {
806813
self.0.push(data.into_u8());
807814
self.1 = Some(data);
@@ -811,6 +818,7 @@ impl Builder {
811818
/// Adds an `OP_VERIFY` to the script, unless the most-recently-added
812819
/// opcode has an alternate `VERIFY` form, in which case that opcode
813820
/// is replaced. e.g. `OP_CHECKSIG` will become `OP_CHECKSIGVERIFY`.
821+
#[must_use]
814822
pub fn push_verify(mut self) -> Builder {
815823
match self.1 {
816824
Some(opcodes::all::OP_EQUAL) => {

0 commit comments

Comments
 (0)