Make tweak_add_assign return statements uniform

We have two `tweak_add_assign` methods (one for keypair and one for
x-only pubkey). Both check the return value from a FFI function call.
We can make both sites uniform to _slightly_ reduce cognitive load when
reading the code.

Use C style code to make it obvious to readers that this is basically C
code.
This commit is contained in:
Tobin Harding 2022-01-04 08:36:46 +11:00
parent edafb88f8c
commit 1b768b2749
1 changed files with 4 additions and 6 deletions

View File

@ -636,12 +636,11 @@ impl KeyPair {
&mut self.0,
tweak.as_c_ptr(),
);
if err == 1 {
Ok(())
} else {
Err(Error::InvalidTweak)
if err != 1 {
return Err(Error::InvalidTweak);
}
Ok(())
}
}
}
@ -846,7 +845,6 @@ impl XOnlyPublicKey {
self.as_c_ptr(),
tweak.as_c_ptr(),
);
if err != 1 {
return Err(Error::InvalidTweak);
}