# Averageable

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive/linq/trait-averageable/

**trait** · [`ferroui-reactive`](/docs/0.5.0/api/ferroui-reactive/) · v0.5.0

```rust
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`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/numeric.rs#L109)

## Members

- [`Sum`](#assoc_type-sum)
- [`Output`](#assoc_type-output)
- [`ZERO`](#assoc_const-zero)
- [`add`](#function-add)
- [`average`](#function-average)
- [`empty`](#function-empty)

<a id="assoc_type-sum"></a>

### Sum

```rust
type Sum: Copy + 'static
```

The running sum.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/numeric.rs#L111)

<a id="assoc_type-output"></a>

### Output

```rust
type Output: 'static
```

The average.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/numeric.rs#L114)

<a id="assoc_const-zero"></a>

### ZERO

```rust
const ZERO: <Self as >::Sum
```

The sum of no values.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/numeric.rs#L117)

<a id="function-add"></a>

### add

```rust
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`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/numeric.rs#L122)

<a id="function-average"></a>

### average

```rust
fn average(sum: <Self as >::Sum, count: i64) -> <Self as >::Output
```

The average of `count` values (at least one) that add up to `sum`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/numeric.rs#L125)

<a id="function-empty"></a>

### empty

```rust
fn empty() -> Option<<Self as >::Output>
```

The value of a sequence without a counted value; `None` ends the sequence with
`SequenceError::NoElements` (`InvalidOperationException`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/numeric.rs#L129)

## Trait implementations

- [`Averageable`](/docs/0.5.0/api/ferroui-reactive/linq/trait-averageable/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
