toml icon indicating copy to clipboard operation
toml copied to clipboard

No `retain` for `Array` and `Table`/`TableLike`

Open jonhoo opened this issue 3 years ago • 1 comments
trafficstars

It's currently pretty painful to remove items matching a given condition from an array or table with toml_edit due to the lack of a retain-like method. You need one "pass" to gather the indices, and clone them if removing from a table, and then a second pass to remove each one, one by one. This is both unergonomic and inefficient. It'd be great to have Array::retain and TableLike::retain to make this kind of "match removal" easier!

jonhoo avatar Mar 04 '22 01:03 jonhoo

Agreed though right now I won't be able to get to this as I'm focused on prep work for cargo-add going into cargo. Contributions would be welcome!

epage avatar Mar 04 '22 01:03 epage

Love you both so I did #575.

retain should already be available to Array because it's a type alias to Vec :) .

marcospb19 avatar Jun 28 '23 05:06 marcospb19

Unlinking #575 to this issue because I did it for the wrong crate :laughing:, I might try again for the right one :sweat_smile: .

marcospb19 avatar Jun 28 '23 15:06 marcospb19

@epage you can close this due to #576.

(I now realize that "Solves" isn't a recognized keyword for linking a PR to an issue.)

marcospb19 avatar Jul 05 '23 19:07 marcospb19