# ChainedComparer

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/comparers/struct-chainedcomparer/

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

```rust
struct ChainedComparer<T>
```

A comparer that applies a parent comparer, then a comparison to break its ties
(`ChainedComparer<T>`): the chain that `then_by` and `order_by` build.

Deviation (DEVIATIONS.md, ReactiveUI): upstream's class is internal; it is public here so that
its tests, in their own crate, reach it. Upstream also returns 0 for two null values before it
asks the comparison; a value here cannot be null, and an optional value compares through the
comparison it is given (`None` equals `None`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/comparers/chained_comparer.rs#L14)

## Members

- [`new`](#function-new)
- [`compare`](#function-compare)
- [`into_comparer`](#function-into_comparer)

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

### new

```rust
fn new(parent: Option<Comparer<T>>, comparison: impl Fn(&T, &T) -> Ordering + 'static) -> Self
```

A comparer that applies `parent`, if any, then `comparison`
(`ChainedComparer(IComparer<T>?, Comparison<T>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/comparers/chained_comparer.rs#L22)

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

### compare

```rust
fn compare(self: &Self, x: &T, y: &T) -> Ordering
```

The order of `x` and `y`: the parent's, unless it finds them equal (`Compare`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/comparers/chained_comparer.rs#L27)

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

### into_comparer

```rust
fn into_comparer(self: Self) -> Comparer<T>
```

The comparer as the shared comparison function that sorting takes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/comparers/chained_comparer.rs#L36)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`

## Availability

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