# Change

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

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

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

A change of one item of a cache (`Change<TObject, TKey>`): its reason, its key, the item and,
for an update, the item it replaced; the indexes for a sorted collection.

Deviation (DEVIATIONS.md, DynamicData): the indexes are `Option<usize>`, where upstream writes
`-1` for no index.

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

## Members

- [`new`](#function-new)
- [`with_index`](#function-with_index)
- [`with_previous`](#function-with_previous)
- [`update`](#function-update)
- [`moved`](#function-moved)
- [`key`](#function-key)
- [`reason`](#function-reason)
- [`current`](#function-current)
- [`previous`](#function-previous)
- [`current_index`](#function-current_index)
- [`previous_index`](#function-previous_index)
- [`into_parts`](#function-into_parts)

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

### new

```rust
fn new(reason: ChangeReason, key: K, current: T) -> Self
```

A change without a previous item (`Change(ChangeReason, TKey, TObject, int index = -1)`).
## Panics
For `ChangeReason::Update`, which needs the previous item (`ArgumentException`).

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

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

### with_index

```rust
fn with_index(reason: ChangeReason, key: K, current: T, index: Option<usize>) -> Self
```

A change with the index of the item (`Change(ChangeReason, TKey, TObject, int index)`).

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

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

### with_previous

```rust
fn with_previous(reason: ChangeReason, key: K, current: T, previous: Option<T>, current_index: Option<usize>, previous_index: Option<usize>) -> Self
```

A change with every part (`Change(ChangeReason, TKey, TObject, in Optional<TObject>, int,
int)`).
## Panics
For `ChangeReason::Add` with a previous item, and for `ChangeReason::Update` without one
(`ArgumentException`).

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

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

### update

```rust
fn update(key: K, current: T, previous: T) -> Self
```

An update of `key` from `previous` to `current` (`Change(ChangeReason.Update, key, current,
previous)`).

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

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

### moved

```rust
fn moved(key: K, current: T, current_index: usize, previous_index: usize) -> Self
```

A move within a sorted collection (`Change(TKey, TObject, int currentIndex, int
previousIndex)`).

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

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

### key

```rust
fn key(self: &Self) -> &K
```

The key of the item (`Key`).

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

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

### reason

```rust
fn reason(self: &Self) -> ChangeReason
```

The reason of the change (`Reason`).

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

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

### current

```rust
fn current(self: &Self) -> &T
```

The item (`Current`).

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

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

### previous

```rust
fn previous(self: &Self) -> Option<&T>
```

The item that an update replaced (`Previous`).

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

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

### current_index

```rust
fn current_index(self: &Self) -> Option<usize>
```

The index of the item in a sorted collection (`CurrentIndex`; `-1` upstream when none).

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

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

### previous_index

```rust
fn previous_index(self: &Self) -> Option<usize>
```

The previous index of the item (`PreviousIndex`).

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

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

### into_parts

```rust
fn into_parts(self: Self) -> (ChangeReason, K, T, Option<T>)
```

The parts of the change, taken apart.

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

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `Equivalent<K>`
- `Clone`
- `StructuralPartialEq`
- `PartialEq`
- `Eq`
- `Hash`
- `Debug`
- `FromIterator<Change<T, K>>`

## Availability

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