Calculates the discriminant of an enum variant.
unsafe extern "rust-intrinsic" fn discriminant_value<T>(v: &T) -> u64
| Name | Description |
|---|---|
| v | The variant whose discriminant will be calculated. |
Returns the discriminant value cast to an u64 or 0 if the argument does not have a discriminant value.
If the discriminant cannot be represented in an i64, the result is unspecified. Note that it is i64, not u64.
enum T {
X,
Y,
}
assert!(unsafe { discriminant_value(&T::X) } == 0);