]> git.proxmox.com Git - rustc.git/blame - vendor/packed_simd/src/api/into_bits.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / vendor / packed_simd / src / api / into_bits.rs
CommitLineData
f20569fa
XL
1//! Implementation of `FromBits` and `IntoBits`.
2
3/// Safe lossless bitwise conversion from `T` to `Self`.
4pub trait FromBits<T>: crate::marker::Sized {
5 /// Safe lossless bitwise transmute from `T` to `Self`.
6 fn from_bits(t: T) -> Self;
7}
8
9/// Safe lossless bitwise conversion from `Self` to `T`.
10pub trait IntoBits<T>: crate::marker::Sized {
11 /// Safe lossless bitwise transmute from `self` to `T`.
12 fn into_bits(self) -> T;
13}
14
15/// `FromBits` implies `IntoBits`.
16impl<T, U> IntoBits<U> for T
17where
18 U: FromBits<T>,
19{
20 #[inline]
21 fn into_bits(self) -> U {
22 debug_assert!(
23 crate::mem::size_of::<Self>() == crate::mem::size_of::<U>()
24 );
25 U::from_bits(self)
26 }
27}
28
29/// `FromBits` and `IntoBits` are reflexive
30impl<T> FromBits<T> for T {
31 #[inline]
32 fn from_bits(t: Self) -> Self {
33 t
34 }
35}
36
37#[macro_use]
38mod macros;
39
40mod v16;
41pub use self::v16::*;
42
43mod v32;
44pub use self::v32::*;
45
46mod v64;
47pub use self::v64::*;
48
49mod v128;
50pub use self::v128::*;
51
52mod v256;
53pub use self::v256::*;
54
55mod v512;
56pub use self::v512::*;
57
58mod arch_specific;
59pub use self::arch_specific::*;