Seal `CheckedSum`
This commit is contained in:
parent
6f7da5f2ef
commit
4dae56908b
|
@ -864,7 +864,7 @@ impl ::std::iter::Sum for SignedAmount {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the sum over the iterator using checked arithmetic.
|
/// Calculate the sum over the iterator using checked arithmetic.
|
||||||
pub trait CheckedSum<R> {
|
pub trait CheckedSum<R>: private::SumSeal<R> {
|
||||||
/// Calculate the sum over the iterator using checked arithmetic. If an over or underflow would
|
/// Calculate the sum over the iterator using checked arithmetic. If an over or underflow would
|
||||||
/// happen it returns `None`.
|
/// happen it returns `None`.
|
||||||
fn checked_sum(self) -> Option<R>;
|
fn checked_sum(self) -> Option<R>;
|
||||||
|
@ -892,6 +892,16 @@ impl<T> CheckedSum<SignedAmount> for T where T: Iterator<Item = SignedAmount> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod private {
|
||||||
|
use ::{Amount, SignedAmount};
|
||||||
|
|
||||||
|
/// Used to seal the `CheckedSum` trait
|
||||||
|
pub trait SumSeal<A> {}
|
||||||
|
|
||||||
|
impl<T> SumSeal<Amount> for T where T: Iterator<Item = Amount> {}
|
||||||
|
impl<T> SumSeal<SignedAmount> for T where T: Iterator<Item = SignedAmount> {}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
pub mod serde {
|
pub mod serde {
|
||||||
// methods are implementation of a standardized serde-specific signature
|
// methods are implementation of a standardized serde-specific signature
|
||||||
|
|
Loading…
Reference in New Issue