Skip to main content

AggregateNumber

Trait AggregateNumber 

Source
pub trait AggregateNumber:
    Copy
    + PartialEq
    + PartialOrd
    + Debug
    + 'static {
    type Average: Copy + PartialEq + PartialOrd + Debug + 'static;

    const ZERO: Self;

    // Required methods
    fn plus(self, other: Self) -> Self;
    fn minus(self, other: Self) -> Self;
    fn average(sum: Self, count: i32) -> Self::Average;
    fn to_average(self) -> Self::Average;
}
Expand description

A number that the aggregations add up and average (int, long, float, double).

Required Associated Constants§

Source

const ZERO: Self

Zero, the sum of no values.

Required Associated Types§

Source

type Average: Copy + PartialEq + PartialOrd + Debug + 'static

The type of an average: f64 for i32, i64 and f64 (double), f32 for f32 (float), as upstream’s overloads of Avg return.

Required Methods§

Source

fn plus(self, other: Self) -> Self

self + other, wrapping on overflow for the integers.

Source

fn minus(self, other: Self) -> Self

self - other, wrapping on overflow for the integers.

Source

fn average(sum: Self, count: i32) -> Self::Average

The average of count values (at least one) whose sum is sum: sum / (double)count for the integers and double, sum / count in float for float.

Source

fn to_average(self) -> Self::Average

The number as an average (the implicit conversion of upstream’s emptyValue).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AggregateNumber for f32

Source§

const ZERO: f32 = 0.0

Source§

type Average = f32

Source§

fn plus(self, other: f32) -> f32

Source§

fn minus(self, other: f32) -> f32

Source§

fn average(sum: f32, count: i32) -> f32

Source§

fn to_average(self) -> f32

Source§

impl AggregateNumber for f64

Source§

const ZERO: f64 = 0.0

Source§

type Average = f64

Source§

fn plus(self, other: f64) -> f64

Source§

fn minus(self, other: f64) -> f64

Source§

fn average(sum: f64, count: i32) -> f64

Source§

fn to_average(self) -> f64

Source§

impl AggregateNumber for i32

Source§

const ZERO: i32 = 0

Source§

type Average = f64

Source§

fn plus(self, other: i32) -> i32

Source§

fn minus(self, other: i32) -> i32

Source§

fn average(sum: i32, count: i32) -> f64

Source§

fn to_average(self) -> f64

Source§

impl AggregateNumber for i64

Source§

const ZERO: i64 = 0

Source§

type Average = f64

Source§

fn plus(self, other: i64) -> i64

Source§

fn minus(self, other: i64) -> i64

Source§

fn average(sum: i64, count: i32) -> f64

Source§

fn to_average(self) -> f64

Implementors§