-
Notifications
You must be signed in to change notification settings - Fork 123
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(is_variant): add #[must_use]
annotation
#350
Conversation
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.
@TheLostLambda thanks for quick reaction!
Let's add few bikesheddings and get it merged!
impl/src/is_variant.rs
Outdated
#enum_name ::#variant_ident #data_pattern => true, | ||
_ => false | ||
} | ||
matches!(self, #enum_name ::#variant_ident #data_pattern) |
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.
For hygiene, this should be used like derive_more::core::matches!
.
@tyranron Ah! Excellent! The I'll get to work addressing these loose ends! |
I just went a little insane trying to figure out why those tests weren't running for me, but it seems the compile fail tests are all disabled on nightly Rust (only running for stable). I think that means all of these tests are missed by CI as well, since there are a couple of failing tests unrelated to my change here. Would you like me to add something to the CI in this PR or remove that stable-only attribute? I assume that was added in the first place to stop things from breaking when the nightly and stable compilers gave different errors, so perhaps just adding a bit in the CI is the best thing to do? EDIT: Actually, they look like they should be running? Let me investigate... |
Conclusion is that I have no idea why that last CI run didn't fail... It looks like things are being run in the I've pushed the changes that make things pass for me locally, so maybe those will break the CI version? They should? TL;DR is that I think I've addressed all of your comments, but, unrelated, I'm not sure if the |
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.
@TheLostLambda this is just some platform-dependent output weirdness.
Overall, now it's LGTM. Thanks!
Resolves #349
Synopsis & Solution
Adds a
#[must_use]
annotation to the static methods generated byIsVariant
. I also refactored the derive to usematches!(...)
instead of a manualmatch
block with bools, but that's just a style tweak.Checklist
I'll be honest, I'm not 100% sure how to write tests for this one, but I have a screenshot of it in action: