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

Allow registry to be cloned #397

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rakshith-ravi
Copy link

Added Clone to registry.

Closes #396

Added Clone to registry
@rakshith-ravi
Copy link
Author

Okay yeah this doesn't seem to fix it. Let me try something else

@sunng87
Copy link
Owner

sunng87 commented Nov 26, 2020

Can you use an Arc for this?

@rakshith-ravi
Copy link
Author

Yup. That's what I'm currently using locally. But I'm trying to get this to Clone directly so that we can make multiple copies of the registry that can work independent of each other. I'm trying to use generic parameters. Will update the PR once I get something running

@rakshith-ravi rakshith-ravi changed the title Update registry.rs Allow registry to be cloned Nov 26, 2020
@sunng87
Copy link
Owner

sunng87 commented Nov 26, 2020

I'm afraid generic parameters may not work for this. Handlebars-rust uses a lot of dynamic dispatch in render and helper API, which makes helpers field not clone-able. I will think about this too.

@sunng87
Copy link
Owner

sunng87 commented Nov 29, 2020

By the way, I have made Registry clone-able in #395

@rakshith-ravi
Copy link
Author

Ahh, I see you made it into an Rc, to make it clone-able. While this works well, it is a little difficult if we need to have multiple copies of the Registry that can be cloned and modified independently. Sure, this can be a solution for now, don't get me wrong. I really appreciate the effort you're taking to fix this, and I would like to thank you for that. But if it's okay, I would like to take some more time to look for another way to make it really cloneable.

@SuperCuber
Copy link

@rakshith-ravi correct me if I'm wrong, but I think right now the registry can be modified independently - it's just the HelperDefs themselves that cannot be. The map itself is cloned so you can just replace the helpers with other ones.

@sunng87 sunng87 force-pushed the master branch 2 times, most recently from 7abfce6 to 4962d7e Compare June 4, 2021 16:55
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.

Registry impl Clone?
3 participants