mirror of
https://github.com/azalea-rs/simdnbt.git
synced 2025-08-02 07:26:04 +00:00
fix unsoundness by sealing SwappableNumber
This commit is contained in:
parent
33b8f0db99
commit
96f73c9de3
1 changed files with 14 additions and 9 deletions
|
@ -1,14 +1,19 @@
|
|||
use std::{mem, simd::prelude::*};
|
||||
|
||||
pub trait SwappableNumber {}
|
||||
impl SwappableNumber for u16 {}
|
||||
impl SwappableNumber for u32 {}
|
||||
impl SwappableNumber for u64 {}
|
||||
impl SwappableNumber for i16 {}
|
||||
impl SwappableNumber for i32 {}
|
||||
impl SwappableNumber for i64 {}
|
||||
impl SwappableNumber for f32 {}
|
||||
impl SwappableNumber for f64 {}
|
||||
mod private {
|
||||
pub trait Sealed {}
|
||||
|
||||
impl Sealed for u16 {}
|
||||
impl Sealed for u32 {}
|
||||
impl Sealed for u64 {}
|
||||
impl Sealed for i16 {}
|
||||
impl Sealed for i32 {}
|
||||
impl Sealed for i64 {}
|
||||
impl Sealed for f32 {}
|
||||
impl Sealed for f64 {}
|
||||
}
|
||||
pub trait SwappableNumber: private::Sealed {}
|
||||
impl<T: private::Sealed> SwappableNumber for T {}
|
||||
|
||||
#[inline]
|
||||
fn swap_endianness_16bit(bytes: &mut [u8], num: usize) {
|
||||
|
|
Loading…
Add table
Reference in a new issue