Use contains combinator instead of manual range

Clippy emits:

  warning: manual `RangeInclusive::contains` implementation

As suggested, use `contains` combinator instead of manual range check.
This commit is contained in:
Tobin C. Harding 2022-05-25 13:24:15 +10:00
parent b7d6c3e02c
commit 14c72e755b
1 changed files with 2 additions and 2 deletions

View File

@ -524,7 +524,7 @@ impl Script {
// special meaning. The value of the first push is called the "version byte". The following // special meaning. The value of the first push is called the "version byte". The following
// byte vector pushed is called the "witness program". // byte vector pushed is called the "witness program".
let script_len = self.0.len(); let script_len = self.0.len();
if script_len < 4 || script_len > 42 { if !(4..=42).contains(&script_len) {
return false return false
} }
let ver_opcode = opcodes::All::from(self.0[0]); // Version 0 or PUSHNUM_1-PUSHNUM_16 let ver_opcode = opcodes::All::from(self.0[0]); // Version 0 or PUSHNUM_1-PUSHNUM_16
@ -876,7 +876,7 @@ impl Builder {
/// dedicated opcodes to push some small integers. /// dedicated opcodes to push some small integers.
pub fn push_int(self, data: i64) -> Builder { pub fn push_int(self, data: i64) -> Builder {
// We can special-case -1, 1-16 // We can special-case -1, 1-16
if data == -1 || (data >= 1 && data <= 16) { if data == -1 || (1..=16).contains(&data) {
let opcode = opcodes::All::from( let opcode = opcodes::All::from(
(data - 1 + opcodes::OP_TRUE.into_u8() as i64) as u8 (data - 1 + opcodes::OP_TRUE.into_u8() as i64) as u8
); );