Averageable
trait · ferroui-reactive · v0.5.0
trait Averageable: Sized + 'static
A type Average averages (upstream's overloads of Average for int, long, float,
double and their nullable forms): the average of i32 and i64 values is an f64 (their
sum is an i64, checked), of f32 values an f32 (their sum an f64), of f64 values an
f64; the average of an Option sequence ignores the None values and is an Option.
Members
Sum
type Sum: Copy + 'static
The running sum.
Output
type Output: 'static
The average.
ZERO
const ZERO: <Self as >::Sum
The sum of no values.
add
fn add(sum: <Self as >::Sum, value: Self) -> Result<Option<<Self as >::Sum>, SequenceError>
sum plus value: Ok(Some(sum)) when the value is counted, Ok(None) when it is
ignored (a None), Err(SequenceError::Overflow) when the sum does not fit (the checked
addition of upstream, which throws OverflowException).
average
fn average(sum: <Self as >::Sum, count: i64) -> <Self as >::Output
The average of count values (at least one) that add up to sum.
empty
fn empty() -> Option<<Self as >::Output>
The value of a sequence without a counted value; None ends the sequence with
SequenceError::NoElements (InvalidOperationException).
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.