-
Notifications
You must be signed in to change notification settings - Fork 13k
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
stabilize const mem::discriminant #73395
Conversation
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
0f72adc
to
d3dacb6
Compare
While I see no reason not to do this, I think the stabilization would benefit from at least mentioning a real world use case that would benefit from this or be possible only with this. |
Now that enum Whatever {
Variant(Foo, Bar, StructWithWierdInvariants),
OtherVariant,
}
const WHATEVER_KIND_DISCR: Discriminant<Whatever> =
mem::discriminant(&Whatever::Kind(...));
fn this_is_a_function(input: Whatever) {
other_function_requiring_discriminant(input, WHATEVER_KIND_DISCR);
} |
That argument is enough for me :D But I think we should keep waiting for a real use case, though I worry we won't get real use cases without it being stable :/ |
☔ The latest upstream changes (presumably #72437) made this pull request unmergeable. Please resolve the merge conflicts. |
Changes
mem::discriminant
to be const stable starting at version 1.46.0closes #69821