# KeyValueComparer

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/cache/struct-keyvaluecomparer/

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

```rust
struct KeyValueComparer<T, K>
```

Compares the pairs of a key and an item of a sorted cache (`KeyValueComparer<TObject, TKey>`):
by the items with the comparer when there is one, then by the keys, so that each pair has a
unique position.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_comparer.rs#L16)

## Members

- [`new`](#function-new)
- [`item_comparer`](#function-item_comparer)
- [`compare`](#function-compare)
- [`to_fn`](#function-to_fn)

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

### new

```rust
fn new(comparer: Option<Rc<dyn Fn(&T, &T) -> Ordering>>) -> Self
```

A comparer of pairs by `comparer`, then by the keys (`KeyValueComparer(IComparer<TObject>?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_comparer.rs#L42)

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

### item_comparer

```rust
fn item_comparer(self: &Self) -> Option<&Rc<dyn Fn(&T, &T) -> Ordering>>
```

The comparer of the items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_comparer.rs#L47)

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

### compare

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

Compares two pairs (`Compare`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_comparer.rs#L54)

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

### to_fn

```rust
fn to_fn(self: &Self) -> Rc<dyn Fn(&(K, T), &(K, T)) -> Ordering>
```

The comparer as a function.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/internal/key_value_comparer.rs#L65)

## Trait implementations

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

## Availability

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