replace_or_append
Replaces the first element that matches with item, or appends item when none does: the
“upsert into a list” gesture.
Import
Section titled “Import”Cargo feature array (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
items | &[T] | The current elements. |
item | T | The replacement, or the new element. |
matches | impl FnMut(&T) -> bool | Tells which existing element item replaces. |
Returns
Section titled “Returns”Vec<T> — A new Vec; items is not changed.
