Mark `checked_` functions const in bitcoin.

Replace `?` operators, which are not allowed in const context, with
match statements.
This commit is contained in:
Jamil Lambert, PhD 2024-11-18 10:50:26 +00:00
parent fe10ff2eb7
commit a8379bf005
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 5 additions and 2 deletions

View File

@ -627,8 +627,11 @@ impl Psbt {
/// Gets the input at `input_index` after checking that it is a valid index.
fn checked_input(&self, input_index: usize) -> Result<&Input, IndexOutOfBoundsError> {
self.check_index_is_within_bounds(input_index)?;
Ok(&self.inputs[input_index])
// No `?` operator in const context.
match self.check_index_is_within_bounds(input_index) {
Ok(_) => Ok(&self.inputs[input_index]),
Err(e) => Err(e),
}
}
/// Checks `input_index` is within bounds for the PSBT `inputs` array and