Skip to content

Commit

Permalink
Mark discriminant as inline
Browse files Browse the repository at this point in the history
This function is very simple, ideally it should be some form of language
intrinsics, but here we are. I could try and see if ther are cases where
compiler wouldn't inline this function. Instead I just put the attribute
... and move on doing something else

Signed-off-by: Ahmed Abdelraoof <[email protected]>
  • Loading branch information
oddcoder committed Aug 11, 2024
1 parent 345a30f commit a45367f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions safe-discriminant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub unsafe trait Discriminant {
/// `#[repr(u*)]` or `#[repr(i*)]`.
type Selector: Copy;
/// Returns the discriminant value of enum variant we are using.
#[inline(always)]
fn discriminant(&self) -> Self::Selector {
unsafe { *<*const _>::from(self).cast() }
}
Expand Down

0 comments on commit a45367f

Please sign in to comment.