toggle_by
Like toggle, but elements are the same when key gives the same value:
toggle objects by id instead of by whole-value equality. Only the first match is removed.
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 element to add, or whose key to remove. |
key | impl FnMut(&T) -> K | Returns the identity to compare. |
Returns
Section titled “Returns”Vec<T> — A new Vec; items is not changed.
