From 4dae56908b76ef8b6ee034e4ccf316a3dabd3d24 Mon Sep 17 00:00:00 2001 From: Sebastian Geisler Date: Wed, 23 Jun 2021 14:18:42 +0200 Subject: [PATCH] Seal `CheckedSum` --- src/util/amount.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/util/amount.rs b/src/util/amount.rs index 13756844..82219b38 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -864,7 +864,7 @@ impl ::std::iter::Sum for SignedAmount { } /// Calculate the sum over the iterator using checked arithmetic. -pub trait CheckedSum { +pub trait CheckedSum: private::SumSeal { /// Calculate the sum over the iterator using checked arithmetic. If an over or underflow would /// happen it returns `None`. fn checked_sum(self) -> Option; @@ -892,6 +892,16 @@ impl CheckedSum for T where T: Iterator { } } +mod private { + use ::{Amount, SignedAmount}; + + /// Used to seal the `CheckedSum` trait + pub trait SumSeal {} + + impl SumSeal for T where T: Iterator {} + impl SumSeal for T where T: Iterator {} +} + #[cfg(feature = "serde")] pub mod serde { // methods are implementation of a standardized serde-specific signature