Skip to content

Commit

Permalink
Use contains combinator instead of manual range
Browse files Browse the repository at this point in the history
Clippy emits:

  warning: manual `RangeInclusive::contains` implementation

As suggested, use `contains` combinator instead of manual range check.
  • Loading branch information
tcharding committed May 25, 2022
1 parent b7d6c3e commit 14c72e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/blockdata/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit 14c72e7

Please sign in to comment.