Closed jrmoulton closed 9 months ago
I'm building a picker that uses a virtual list. The virtual list requires an item of which it can take a slice.
Using the visual list makes it so that I don't necessarily know which items from the snapshot I need when the snapshot is finished and defers that decision to some later time based on scrolling of the virtual list. Cloning the snapshot fits this use case very well.
It would be nice if the Vec<Match>
was a cheaper clone (maybe using im::Vector) but cloning here didn't seem too unreasonable.
Although maybe I'm just missing the obvious way to implement this without cloning.
Without seeing specific code it's hard to tell but I am highly skeptical that you really need to clone the snapshot. This seems like the exact situation that not making it clone was supposed to prevent.
Everytime you want to access the snapshot you should just call tick. The snapshot already allows slicing.
What is your usecase? It's intentional that snapshot doesn't implement clone. It's supposed to be a snapshot view of an internal buffer. Not something you store longterm or pass around