diff --git a/bitcoin/src/blockdata/script/instruction.rs b/bitcoin/src/blockdata/script/instruction.rs index 575ba6311..16cd1df45 100644 --- a/bitcoin/src/blockdata/script/instruction.rs +++ b/bitcoin/src/blockdata/script/instruction.rs @@ -231,7 +231,7 @@ impl<'a> InstructionIndices<'a> { let prev_remaining = self.remaining_bytes(); let prev_pos = self.pos; let instruction = next_fn(self)?; - // No underflow: there must be less remaining bytes now than previously + // No overflow: there must be less remaining bytes now than previously let consumed = prev_remaining - self.remaining_bytes(); // No overflow: sum will never exceed slice length which itself can't exceed `usize` self.pos += consumed; diff --git a/bitcoin/src/taproot/serialized_signature.rs b/bitcoin/src/taproot/serialized_signature.rs index 2bc849b84..be388e2c3 100644 --- a/bitcoin/src/taproot/serialized_signature.rs +++ b/bitcoin/src/taproot/serialized_signature.rs @@ -217,7 +217,7 @@ mod into_iter { #[inline] fn size_hint(&self) -> (usize, Option) { - // can't underflow thanks to the invariant + // can't overflow thanks to the invariant let len = self.signature.len() - self.pos; (len, Some(len)) } diff --git a/units/src/amount/mod.rs b/units/src/amount/mod.rs index 8af21f0a1..7fb8bc535 100644 --- a/units/src/amount/mod.rs +++ b/units/src/amount/mod.rs @@ -588,8 +588,8 @@ enum DisplayStyle { /// Calculates the sum over the iterator using checked arithmetic. pub trait CheckedSum: sealed::Sealed { - /// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would - /// happen it returns [`None`]. + /// Calculates the sum over the iterator using checked arithmetic. If an + /// overflow happens it returns [`None`]. fn checked_sum(self) -> Option; } diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index f51be5570..7551ac197 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -25,10 +25,10 @@ use super::{ /// Warning! /// /// This type implements several arithmetic operations from [`core::ops`]. -/// To prevent errors due to overflow or underflow when using these operations, +/// To prevent errors due to an overflow when using these operations, /// it is advised to instead use the checked arithmetic methods whose names /// start with `checked_`. The operations from [`core::ops`] that [`SignedAmount`] -/// implements will panic when overflow or underflow occurs. +/// implements will panic when an overflow occurs. /// /// # Examples /// diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs index c52a8f2c5..89d7eb35f 100644 --- a/units/src/amount/unsigned.rs +++ b/units/src/amount/unsigned.rs @@ -22,17 +22,6 @@ use super::{ /// conversion to various denominations. The [`Amount`] type does not implement [`serde`] traits /// but we do provide modules for serializing as satoshis or bitcoin. /// -/// Warning! -/// -/// This type implements several arithmetic operations from [`core::ops`]. -/// To prevent errors due to overflow or underflow when using these operations, -/// it is advised to instead use the checked arithmetic methods whose names -/// start with `checked_`. The operations from [`core::ops`] that [`Amount`] -/// implements will panic when overflow or underflow occurs. Also note that -/// since the internal representation of amounts is unsigned, subtracting below -/// zero is considered an underflow and will cause a panic if you're not using -/// the checked arithmetic methods. -/// /// # Examples /// /// ```