Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Clone on Snapshot #39

Closed
wants to merge 1 commit into from
Closed

Conversation

jrmoulton
Copy link

No description provided.

@pascalkuthe
Copy link
Member

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

@jrmoulton
Copy link
Author

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.

@pascalkuthe
Copy link
Member

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.

@jrmoulton jrmoulton closed this Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants