pub trait SumPromotion<Count>: Copy + Into<Self::Sum> + 'static
where Count: Into<Self::Sum>,
{ type Sum: Zero + NumOps + NumAssignOps + AsPrimitive<Self>; }
Expand description

A numerical trait used to prevent overflow when summing any Count number of Selfs.

That is, the Sum type needs to be able to represent the value Count::MAX * Self::MAX without overflowing. For floating point types, this constraint is relaxed, and the Sum type simply needs to have more precision (if possible).

Required Associated Types§

source

type Sum: Zero + NumOps + NumAssignOps + AsPrimitive<Self>

The promotion type used for the sum.

For integral types, this needs to be able to represent the value Count::MAX * Self::MAX without overflowing.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl SumPromotion<u32> for f32

§

type Sum = f64

source§

impl SumPromotion<u32> for f64

§

type Sum = f64

source§

impl SumPromotion<u32> for u8

§

type Sum = u64

source§

impl SumPromotion<u32> for u16

§

type Sum = u64

Implementors§