From c75189841a11e54e272c96ff8bd7feb7b0567880 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 25 May 2022 13:28:31 +1000 Subject: [PATCH] Remove unnecessary closure Clippy emits: warning: unnecessary closure used to substitute value for `Option::None` As suggested, use `ok_or` removing the unnecessary closure. --- src/blockdata/witness.rs | 4 ++-- src/util/sighash.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/blockdata/witness.rs b/src/blockdata/witness.rs index 41582654..b37f5071 100644 --- a/src/blockdata/witness.rs +++ b/src/blockdata/witness.rs @@ -67,12 +67,12 @@ impl Decodable for Witness { let element_size = element_size_varint.0 as usize; let required_len = cursor .checked_add(element_size) - .ok_or_else(|| self::Error::OversizedVectorAllocation { + .ok_or(self::Error::OversizedVectorAllocation { requested: usize::max_value(), max: MAX_VEC_SIZE, })? .checked_add(element_size_varint_len) - .ok_or_else(|| self::Error::OversizedVectorAllocation { + .ok_or(self::Error::OversizedVectorAllocation { requested: usize::max_value(), max: MAX_VEC_SIZE, })?; diff --git a/src/util/sighash.rs b/src/util/sighash.rs index 63b1a147..d34690b8 100644 --- a/src/util/sighash.rs +++ b/src/util/sighash.rs @@ -440,7 +440,7 @@ impl> SighashCache { .tx .input .get(input_index) - .ok_or_else(|| Error::IndexOutOfInputsBounds { + .ok_or(Error::IndexOutOfInputsBounds { index: input_index, inputs_size: self.tx.input.len(), })?; @@ -473,7 +473,7 @@ impl> SighashCache { self.tx .output .get(input_index) - .ok_or_else(|| Error::SingleWithoutCorrespondingOutput { + .ok_or(Error::SingleWithoutCorrespondingOutput { index: input_index, outputs_size: self.tx.output.len(), })? @@ -597,7 +597,7 @@ impl> SighashCache { .tx .input .get(input_index) - .ok_or_else(|| Error::IndexOutOfInputsBounds { + .ok_or(Error::IndexOutOfInputsBounds { index: input_index, inputs_size: self.tx.input.len(), })?;