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

Clone unexpectedly doesn't clone contents #8

Open
nappa85 opened this issue Nov 6, 2024 · 1 comment
Open

Clone unexpectedly doesn't clone contents #8

nappa85 opened this issue Nov 6, 2024 · 1 comment

Comments

@nappa85
Copy link

nappa85 commented Nov 6, 2024

Being the main struct internally an Arc<Inner>, when the user clones it's simply getting a new smart pointer to the same underlying data, that would be unexpected if paragoned to std HashMap.

Plus, in some examples, ShardMap is wrapped in an Arc, making it a double level of indirection without gainin nothing.

I think in Rust philosophy Arc should be user's duty and not hardcoded inside the struct.

@willothy
Copy link
Member

willothy commented Nov 9, 2024

I've gone back and forth a few times about this - I totally agree that leaving Arc-ing something up to the API consumer, but I also want to allow holding strong references into a specific shard for a 'static lifetime at some point, which would require an Arc'd map.

Right now, I'm thinking of implementing some methods specifically for self: Arc<Self> so that I can allow holding strong references if the type is wrapped in an Arc but still leave that up to the user. Thoughts?

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

No branches or pull requests

2 participants