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

feat: implement Clone for MemoryDB #52

Closed
wants to merge 1 commit into from

Conversation

Wodann
Copy link

@Wodann Wodann commented Mar 28, 2023

Performs a deep clone, creating a separate storage

@Pencil-Yao
Copy link
Member

https://github.com/citahub/cita-trie/blob/0de727ce4835810dd8d5e6a1ef28d73ae2e3f4da/src/db.rs#L48 Because using Arc wrap map, so we prefer use default clone. If you need deep clone you can add a method to achieve it. Ty for your pr.

@Pencil-Yao Pencil-Yao closed this Sep 11, 2023
@Wodann
Copy link
Author

Wodann commented Sep 11, 2023

Given that a deep clone can only be made with access to the private member variables, is it okay to add a deep clone method to the public API? If so, what would you like it to be called @Pencil-Yao?

@Pencil-Yao
Copy link
Member

Achieve deep copy would not make the storage field be public. Operate MemoryDB object only can use public method, so it's safe, don't worry.
I would like the function interface like
pub fn deep_copy(&self) -> Self
I'm open. @Wodann

@Wodann Wodann deleted the feat/clone branch March 7, 2024 20:05
@Wodann
Copy link
Author

Wodann commented Mar 7, 2024

New PR created for deep_clone: #56

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