Skip to content

Commit

Permalink
Merge pull request #187 from flier/repr_transparent
Browse files Browse the repository at this point in the history
add #[repr(transparent)]
  • Loading branch information
KodrAus committed Jul 19, 2021
2 parents 46a2c8e + 869ff95 commit efab7f3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/lib.rs
Expand Up @@ -325,6 +325,7 @@ macro_rules! bitflags {
$($t:tt)*
) => {
$(#[$outer])*
#[repr(transparent)]
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
$vis struct $BitFlags {
bits: $T,
Expand Down Expand Up @@ -500,7 +501,7 @@ macro_rules! __impl_bitflags {
)*
}
}
}
}

/// Returns the raw value of the flags currently stored.
#[inline]
Expand Down Expand Up @@ -930,12 +931,12 @@ mod tests {
unsafe { Flags::from_bits_unchecked(0b1001) },
(extra | Flags::A)
);

let extra = unsafe { EmptyFlags::from_bits_unchecked(0b1000) };
assert_eq!(
unsafe { EmptyFlags::from_bits_unchecked(0b1000) },
(extra | EmptyFlags::empty())
);
unsafe { EmptyFlags::from_bits_unchecked(0b1000) },
(extra | EmptyFlags::empty())
);
}

#[test]
Expand Down Expand Up @@ -1198,10 +1199,7 @@ mod tests {
"A | B | C | ABC | 0xb8"
);

assert_eq!(
format!("{:?}", EmptyFlags::empty()),
"(empty)"
);
assert_eq!(format!("{:?}", EmptyFlags::empty()), "(empty)");
}

#[test]
Expand Down

0 comments on commit efab7f3

Please sign in to comment.