1616/// Converts masks to and from integer bitmasks.
1717///
1818/// Each bit of the bitmask corresponds to a mask lane, starting with the LSB.
19- ///
20- /// # Safety
21- /// This trait is `unsafe` and sealed, since the `BitMask` type must match the number of lanes in
22- /// the mask.
23- pub unsafe trait ToBitMask : Sealed {
19+ pub trait ToBitMask : Sealed {
2420 /// The integer bitmask type.
2521 type BitMask ;
2622
@@ -34,12 +30,8 @@ pub unsafe trait ToBitMask: Sealed {
3430/// Converts masks to and from byte array bitmasks.
3531///
3632/// Each bit of the bitmask corresponds to a mask lane, starting with the LSB of the first byte.
37- ///
38- /// # Safety
39- /// This trait is `unsafe` and sealed, since the `BYTES` value must match the number of lanes in
40- /// the mask.
4133#[ cfg( feature = "generic_const_exprs" ) ]
42- pub unsafe trait ToBitMaskArray : Sealed {
34+ pub trait ToBitMaskArray : Sealed {
4335 /// The length of the bitmask array.
4436 const BYTES : usize ;
4537
@@ -51,9 +43,9 @@ pub unsafe trait ToBitMaskArray: Sealed {
5143}
5244
5345macro_rules! impl_integer_intrinsic {
54- { $( unsafe impl ToBitMask <BitMask =$int: ty> for Mask <_, $lanes: literal>) * } => {
46+ { $( impl ToBitMask <BitMask =$int: ty> for Mask <_, $lanes: literal>) * } => {
5547 $(
56- unsafe impl <T : MaskElement > ToBitMask for Mask <T , $lanes> {
48+ impl <T : MaskElement > ToBitMask for Mask <T , $lanes> {
5749 type BitMask = $int;
5850
5951 fn to_bitmask( self ) -> $int {
@@ -69,13 +61,13 @@ macro_rules! impl_integer_intrinsic {
6961}
7062
7163impl_integer_intrinsic ! {
72- unsafe impl ToBitMask <BitMask =u8 > for Mask <_, 1 >
73- unsafe impl ToBitMask <BitMask =u8 > for Mask <_, 2 >
74- unsafe impl ToBitMask <BitMask =u8 > for Mask <_, 4 >
75- unsafe impl ToBitMask <BitMask =u8 > for Mask <_, 8 >
76- unsafe impl ToBitMask <BitMask =u16 > for Mask <_, 16 >
77- unsafe impl ToBitMask <BitMask =u32 > for Mask <_, 32 >
78- unsafe impl ToBitMask <BitMask =u64 > for Mask <_, 64 >
64+ impl ToBitMask <BitMask =u8 > for Mask <_, 1 >
65+ impl ToBitMask <BitMask =u8 > for Mask <_, 2 >
66+ impl ToBitMask <BitMask =u8 > for Mask <_, 4 >
67+ impl ToBitMask <BitMask =u8 > for Mask <_, 8 >
68+ impl ToBitMask <BitMask =u16 > for Mask <_, 16 >
69+ impl ToBitMask <BitMask =u32 > for Mask <_, 32 >
70+ impl ToBitMask <BitMask =u64 > for Mask <_, 64 >
7971}
8072
8173/// Returns the minimum numnber of bytes in a bitmask with `lanes` lanes.
@@ -85,7 +77,7 @@ pub const fn bitmask_len(lanes: usize) -> usize {
8577}
8678
8779#[ cfg( feature = "generic_const_exprs" ) ]
88- unsafe impl < T : MaskElement , const LANES : usize > ToBitMaskArray for Mask < T , LANES >
80+ impl < T : MaskElement , const LANES : usize > ToBitMaskArray for Mask < T , LANES >
8981where
9082 LaneCount < LANES > : SupportedLaneCount ,
9183{
0 commit comments