Closed Chriscbr closed 9 months ago
The Copy constraint on values seemed like it was necessary at some point, but at least from what I can see, there's no hard requirement on it. The only possible limitation is that SparseMap::update needs to accept a Fn(&V) -> V instead of Fn(V) -> V since it's not possible to safely map and replace a value at the same time (https://stackoverflow.com/questions/67461269/replace-a-value-behind-a-mutable-reference-by-moving-and-mapping-the-original).
Copy
SparseMap::update
Fn(&V) -> V
Fn(V) -> V
Breaking changes:
SparseMap::remove
f: F
F: Fn(&V) -> V
F: Fn(V) -> V
(I should break some of these changes into separate PRs, don't follow my coding practices too closely...)
The
Copy
constraint on values seemed like it was necessary at some point, but at least from what I can see, there's no hard requirement on it. The only possible limitation is thatSparseMap::update
needs to accept aFn(&V) -> V
instead ofFn(V) -> V
since it's not possible to safely map and replace a value at the same time (https://stackoverflow.com/questions/67461269/replace-a-value-behind-a-mutable-reference-by-moving-and-mapping-the-original).Breaking changes:
SparseMap::remove
now returns OptionSparseMap::update
now acceptsf: F
whereF: Fn(&V) -> V
instead ofF: Fn(V) -> V
.