From 14c72e755b1197ec29534cc18aa728b0ac18a4fa Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 25 May 2022 13:24:15 +1000 Subject: [PATCH] Use contains combinator instead of manual range Clippy emits: warning: manual `RangeInclusive::contains` implementation As suggested, use `contains` combinator instead of manual range check. --- src/blockdata/script.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index 4e3151cd..6686c06b 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -524,7 +524,7 @@ impl Script { // special meaning. The value of the first push is called the "version byte". The following // byte vector pushed is called the "witness program". let script_len = self.0.len(); - if script_len < 4 || script_len > 42 { + if !(4..=42).contains(&script_len) { return false } 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. pub fn push_int(self, data: i64) -> Builder { // 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( (data - 1 + opcodes::OP_TRUE.into_u8() as i64) as u8 );