Skip to content

Commit a45367f

Browse files
author
Ahmed Abdelraoof
committed
Mark discriminant as inline
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 <ahmed.abdelraoof@huawei.com>
1 parent 345a30f commit a45367f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

safe-discriminant/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub unsafe trait Discriminant {
5555
/// `#[repr(u*)]` or `#[repr(i*)]`.
5656
type Selector: Copy;
5757
/// Returns the discriminant value of enum variant we are using.
58+
#[inline(always)]
5859
fn discriminant(&self) -> Self::Selector {
5960
unsafe { *<*const _>::from(self).cast() }
6061
}

0 commit comments

Comments
 (0)