repr_discriminant/
lib.rs

1//! A library to obtain the representation of an enum's discriminant.
2
3/// A trait to obtain the representation of an enum's discriminant.
4///
5/// # Safety
6///
7/// The implementor must ensure that the enum is annotated with `#[repr(Self::Repr)]`
8#[expect(unsafe_code)]
9pub unsafe trait ReprDiscriminant {
10    /// The representation type of the discriminant.
11    type Repr;
12
13    /// Returns the representation of the enum's discriminant.
14    fn repr_discriminant(&self) -> Self::Repr;
15}
16
17#[cfg(feature = "derive")]
18pub use repr_discriminant_derive::ReprDiscriminant;