Skip to content

Commit 2e70cd0

Browse files
committed
Do not manually convert bool to integer
Clippy emits: warning: boolean to int conversion using if As suggested use `usize::from`
1 parent c4ab53e commit 2e70cd0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/miniscript/astelem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
775775
Terminal::Check(ref sub) => sub.node.script_size() + 1,
776776
Terminal::DupIf(ref sub) => sub.node.script_size() + 3,
777777
Terminal::Verify(ref sub) => {
778-
sub.node.script_size() + if sub.ext.has_free_verify { 0 } else { 1 }
778+
sub.node.script_size() + usize::from(!sub.ext.has_free_verify)
779779
}
780780
Terminal::NonZero(ref sub) => sub.node.script_size() + 4,
781781
Terminal::ZeroNotEqual(ref sub) => sub.node.script_size() + 1,

src/miniscript/types/extra_props.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ impl Property for ExtData {
443443
}
444444

445445
fn cast_verify(self) -> Result<Self, ErrorKind> {
446-
let verify_cost = if self.has_free_verify { 0 } else { 1 };
446+
let verify_cost = usize::from(!self.has_free_verify);
447447
Ok(ExtData {
448-
pk_cost: self.pk_cost + if self.has_free_verify { 0 } else { 1 },
448+
pk_cost: self.pk_cost + usize::from(!self.has_free_verify),
449449
has_free_verify: false,
450450
ops: OpLimits::new(verify_cost + self.ops.count, self.ops.sat, None),
451451
stack_elem_count_sat: self.stack_elem_count_sat,

src/miniscript/types/malleability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl Property for Malleability {
309309
let mut all_are_non_malleable = true;
310310
for i in 0..n {
311311
let subtype = sub_ck(i)?;
312-
safe_count += if subtype.safe { 1 } else { 0 };
312+
safe_count += usize::from(subtype.safe);
313313
all_are_dissat_unique &= subtype.dissat == Dissat::Unique;
314314
all_are_non_malleable &= subtype.non_malleable;
315315
}

0 commit comments

Comments
 (0)