diff --git a/units/src/amount/mod.rs b/units/src/amount/mod.rs index 21eb9ed8c..db027a191 100644 --- a/units/src/amount/mod.rs +++ b/units/src/amount/mod.rs @@ -527,6 +527,7 @@ pub struct Display { impl Display { /// Makes subsequent calls to `Display::fmt` display denomination. + #[must_use] pub fn show_denomination(mut self) -> Self { match &mut self.style { DisplayStyle::FixedDenomination { show_denomination, .. } => *show_denomination = true, diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index 4237ba0bb..1061a575a 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -206,6 +206,7 @@ impl SignedAmount { // Some arithmetic that doesn't fit in [`core::ops`] traits. /// Get the absolute value of this [`SignedAmount`]. + #[must_use] pub fn abs(self) -> SignedAmount { SignedAmount(self.0.abs()) } /// Gets the absolute value of this [`SignedAmount`] returning [`Amount`]. @@ -307,6 +308,7 @@ impl SignedAmount { /// # Panics /// /// On overflow, panics in debug mode, wraps in release mode. + #[must_use] pub fn unchecked_add(self, rhs: SignedAmount) -> SignedAmount { Self(self.0 + rhs.0) } /// Unchecked subtraction. @@ -316,6 +318,7 @@ impl SignedAmount { /// # Panics /// /// On overflow, panics in debug mode, wraps in release mode. + #[must_use] pub fn unchecked_sub(self, rhs: SignedAmount) -> SignedAmount { Self(self.0 - rhs.0) } /// Subtraction that doesn't allow negative [`SignedAmount`]s. diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs index 9b96c4d51..af43e631b 100644 --- a/units/src/amount/unsigned.rs +++ b/units/src/amount/unsigned.rs @@ -318,6 +318,7 @@ impl Amount { /// # Panics /// /// On overflow, panics in debug mode, wraps in release mode. + #[must_use] pub fn unchecked_add(self, rhs: Amount) -> Amount { Self(self.0 + rhs.0) } /// Unchecked subtraction. @@ -327,6 +328,7 @@ impl Amount { /// # Panics /// /// On overflow, panics in debug mode, wraps in release mode. + #[must_use] pub fn unchecked_sub(self, rhs: Amount) -> Amount { Self(self.0 - rhs.0) } /// Converts to a signed amount. diff --git a/units/src/lib.rs b/units/src/lib.rs index b9e7e960a..59bc16205 100644 --- a/units/src/lib.rs +++ b/units/src/lib.rs @@ -11,6 +11,8 @@ #![warn(missing_docs)] #![warn(deprecated_in_future)] #![doc(test(attr(warn(unused))))] +// Pedantic lints that we enforce. +#![warn(clippy::return_self_not_must_use)] // Exclude lints we don't think are valuable. #![allow(clippy::needless_question_mark)] // https://github.com/rust-bitcoin/rust-bitcoin/pull/2134 #![allow(clippy::manual_range_contains)] // More readable than clippy's format.