units: Add pedantic lint return_self_not_must_use
As part of the effort to polish the `units` create ready for the 1.0 release; enable the pedantic lint `return_self_not_must_use`.
This commit is contained in:
parent
e7efdd7c42
commit
79a229b391
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue