-
Notifications
You must be signed in to change notification settings - Fork 95
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
WIP: ShallowCopy for Option<T> (and more) #48
Conversation
Oooh, exciting! I'm a bit strapped for time, but here are some quick thoughts to get the conversation going:
How often does this come up? My expectation was that implementations of
Removing
Seems like a great idea!
This seems reasonable to me. It's a breaking change, but a good one. The docs for
I like this idea. What do you think of the name
Makes sense to me!
Absolutely.
Do you mean
Yeah, that makes sense. I'll also leave some notes about specifics that you didn't list above! As for commits, having distinct changes in their own commit is nice, but not necessary. It mostly makes pinpointing where bugs are introduced years from now easier :) |
I'll fix the other things you brought up in a moment here, but quick responses to your comments:
It's extremely useful when you have structs as values that don't exclusively contain
Yeah, that's what I meant. |
I've added the requested changes in an extra commit for quick review - once you're happy with all of it, I'll rebase it into something a little more structured. Added clarification to the derive macro point: I'm using multiple structs of primitives and strings, so they can't be |
So, in my use-cases, I "solve" this by allocating the offending value type behind a I'm inclined to include |
That was my thought process as well - it only works on structs/enums if all of their fields already implement Speaking of which, I wonder whether there's a way around having to unwrap and then re-wrap with |
Since I think I agree with you re |
I made a few more changes - let me know whether the name One more thing: Do you think |
So, my thinking for And no, sadly, |
I added some tests and fixed the existing ones - let me know if there's anything else! |
I added one more convenience function to cover a pattern I found myself using very commonly, Again, I'm not sure how specific that is to my use case, so I'll leave it up to you whether it's something you'd be interested in merging in. |
I think |
I think that should cover all of your feedback so far! |
Yup, I think we're very close now! The negative tests are, I think, the only thing really missing. Plus metadata and docs for the As an aside, what do you think of naming the derive crate |
What kind of negative tests do you mean? Isn't that what's in In terms of docs, are you just looking for a README.md, or something more in-depth? I'm not really sure what I'd document since it's "just a derive macro"; it doesn't do anything unusual and offers no configuration - but anything specific you'd like, I can add. I personally think |
@MayaWolf How about adding a |
Hmm...if we could make I say make it configurable since I don't think it would make sense to use smallvec for anything above size 1 in that use case, since otherwise they'd just need to be temporarily hashed in the iterator anyway. |
Hmm, making Forwarding access to Not sure all of ^ would be worth it. Another option is to make the variants of |
I'm curious what you think about this one! I went for the second option you proposed, exposing the inner value storage directly. It allows the user to specify which inner value storage they would like to use - with the built-in choices currently being The changeset for this is pretty large, but that's mostly because I had to change generic parameters in a lot of places. I also removed some of the stuff I added in previous commits, as it wasn't really applicable or necessary anymore. In the case of I tested this using both Let me know what you think about this and, if you like it, what you'd like me to add! Oh, one more thing: The implementation of |
Ah, hmm, no, that wasn't quite what I had in mind with my second suggestion. It was much simpler: just replace I think the proposed change overcomplicates the interface beyond what I'd like. It also makes some of the operations pretty weird in terms of semantics. I think, for what you need, these are the modifications to make:
Your code should then have all it needs to work only with values with distinct sets (I think). |
My thoughts were that I did omit the impl for dynamic smallvec+hashbag since I wasn't sure how necessary it would be (the user could just choose an optimal value-bag type themselves) but it could be added very easily to use as a reasonable default. Overall, I do think this has potential for making things easier and more versatile to work with, but ultimately it's of course entirely up to you; if you'd prefer me to revert the last part I will. |
I think we maybe talked past each other — my worry with your proposed approach is that the semantics of each I think what I'd prefer is to land this PR without the last commit, and then we open a new PR where we see if we can find a way to make that more sweeping change in isolation :) |
Makes a lot of sense, yeah! This one should be ready for merge now; I'll open another PR once it is! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this now!
Only thing missing is to have CI also run for evmap-derive
. Once crate-ci/azure-pipelines#80 lands, it should just be a matter of copying https://github.com/jonhoo/rust-evmap/blob/6238a4a6219b3546ceef5fc55996db954571321c/azure-pipelines.yml#L2-L4 and adding the dir
parameter!
Also, quick not on commit messages: it's usually best to keep the first line brief (50 chars), so that it does not get cut off in various UIs (like GitHub's). Then an empty line, and then a more detailed explanation of the change wrapped at 72 chars. There are a lot of resources on line on exact how/why (like this one), but at least keeping the first line short is nice for GitHub specifically! |
Hi! Sorry this took me so long to get back to, I haven't really been able to work on Rust stuff at all for a little while. I've been trying a few ways of getting CI to work; unfortunately I've never worked with Azure pipelines before so I'm not super familiar with how the setup works there. When I try to simply add
below the existing lines, it complains about duplicated job names, and with the way I've set it up now, it complains about the format of |
No worries at all — life takes precedence :) Ah, yes, that's a little awkward. I think I'd just bypass the template and add: - job: derive
displayName: "Test evmap-derive"
pool:
vmImage: ubuntu-latest
steps:
- template: install-rust.yml@templates
- script: cargo test
displayName: cargo test Probably just above the |
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
==========================================
- Coverage 82.70% 80.69% -2.02%
==========================================
Files 11 11
Lines 977 984 +7
==========================================
- Hits 808 794 -14
- Misses 169 190 +21
Continue to review full report at Codecov.
|
This is looking great — thanks for tidying up the commits, it made reviewing much easier. I left two relatively minor comments :) |
It looks like the
The same appears to be the case for I wasn't planning on raising this, but since some last changes may have to be made, I think the docs in |
…urn non-wrapped values
…e ReadGuard iterable directly, and remove Sync requirement from Predicate
…dd Default derive to CopyValue
Let me know whether you're happy with this! |
This is great, thank you for sticking with it! 🎉 |
Hi there!
As mentioned in #47, I'm using evmap in a (soon-to-be) production project, and ended up making some changes to make evmap easier for my personal use - and I figured some of them might be interesting to you as well. I am merely presenting this to you as a list of things to pick and choose from - tell me which ones you'd be interested in merging, and I'll remove the rest from this PR. Also if there are any code style/documentation/naming/other changes you'd like me to make (including splitting things up into multiple commits/PRs), just let me know!
Predicate
forreject
- it's not actually sent across threads, so there's no need for it from what I could seemap.get(&key).iter().flatten()
)single
functions to the read modules - allows for simple and efficient reading of single valuescontains_value
convenience function to the read modulesThis change is