Skip to content

Commit

Permalink
Remove unnecessary closure
Browse files Browse the repository at this point in the history
Clippy emits:

  warning: unnecessary closure used to substitute value for
  `Option::None`

As suggested, use `ok_or` removing the unnecessary closure.
  • Loading branch information
tcharding committed May 25, 2022
1 parent dfff853 commit c751898
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/blockdata/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})?;
Expand Down
6 changes: 3 additions & 3 deletions src/util/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ impl<R: Deref<Target = Transaction>> SighashCache<R> {
.tx
.input
.get(input_index)
.ok_or_else(|| Error::IndexOutOfInputsBounds {
.ok_or(Error::IndexOutOfInputsBounds {
index: input_index,
inputs_size: self.tx.input.len(),
})?;
Expand Down Expand Up @@ -473,7 +473,7 @@ impl<R: Deref<Target = Transaction>> SighashCache<R> {
self.tx
.output
.get(input_index)
.ok_or_else(|| Error::SingleWithoutCorrespondingOutput {
.ok_or(Error::SingleWithoutCorrespondingOutput {
index: input_index,
outputs_size: self.tx.output.len(),
})?
Expand Down Expand Up @@ -597,7 +597,7 @@ impl<R: Deref<Target = Transaction>> SighashCache<R> {
.tx
.input
.get(input_index)
.ok_or_else(|| Error::IndexOutOfInputsBounds {
.ok_or(Error::IndexOutOfInputsBounds {
index: input_index,
inputs_size: self.tx.input.len(),
})?;
Expand Down

0 comments on commit c751898

Please sign in to comment.