Support Zeroable and Pod for f16 and f128 (#251)

These are gated under a new feature flag `nightly_float`.

Fixes: <https://github.com/Lokathor/bytemuck/issues/250>
This commit is contained in:
Trevor Gross 2024-06-18 22:24:29 -05:00 committed by GitHub
parent d15b8e0e6d
commit 9b81537c5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 0 deletions

View File

@ -42,6 +42,8 @@ unsound_ptr_pod_impl = []
# NOT SEMVER SUPPORTED! TEMPORARY ONLY! # NOT SEMVER SUPPORTED! TEMPORARY ONLY!
nightly_portable_simd = [] nightly_portable_simd = []
nightly_stdsimd = [] nightly_stdsimd = []
# Enable `f16` and `f128`
nightly_float = []
# Improved documentation using the nightly toolchain # Improved documentation using the nightly toolchain
nightly_docs = [] nightly_docs = []

View File

@ -6,6 +6,7 @@
#![allow(clippy::type_complexity)] #![allow(clippy::type_complexity)]
#![cfg_attr(feature = "nightly_docs", feature(doc_cfg))] #![cfg_attr(feature = "nightly_docs", feature(doc_cfg))]
#![cfg_attr(feature = "nightly_portable_simd", feature(portable_simd))] #![cfg_attr(feature = "nightly_portable_simd", feature(portable_simd))]
#![cfg_attr(feature = "nightly_float", feature(f16, f128))]
#![cfg_attr( #![cfg_attr(
all( all(
feature = "nightly_stdsimd", feature = "nightly_stdsimd",

View File

@ -49,8 +49,12 @@ unsafe impl Pod for usize {}
unsafe impl Pod for isize {} unsafe impl Pod for isize {}
unsafe impl Pod for u128 {} unsafe impl Pod for u128 {}
unsafe impl Pod for i128 {} unsafe impl Pod for i128 {}
#[cfg(feature = "nightly_float")]
unsafe impl Pod for f16 {}
unsafe impl Pod for f32 {} unsafe impl Pod for f32 {}
unsafe impl Pod for f64 {} unsafe impl Pod for f64 {}
#[cfg(feature = "nightly_float")]
unsafe impl Pod for f128 {}
unsafe impl<T: Pod> Pod for Wrapping<T> {} unsafe impl<T: Pod> Pod for Wrapping<T> {}
#[cfg(feature = "unsound_ptr_pod_impl")] #[cfg(feature = "unsound_ptr_pod_impl")]

View File

@ -48,8 +48,12 @@ unsafe impl Zeroable for usize {}
unsafe impl Zeroable for isize {} unsafe impl Zeroable for isize {}
unsafe impl Zeroable for u128 {} unsafe impl Zeroable for u128 {}
unsafe impl Zeroable for i128 {} unsafe impl Zeroable for i128 {}
#[cfg(feature = "nightly_float")]
unsafe impl Zeroable for f16 {}
unsafe impl Zeroable for f32 {} unsafe impl Zeroable for f32 {}
unsafe impl Zeroable for f64 {} unsafe impl Zeroable for f64 {}
#[cfg(feature = "nightly_float")]
unsafe impl Zeroable for f128 {}
unsafe impl<T: Zeroable> Zeroable for Wrapping<T> {} unsafe impl<T: Zeroable> Zeroable for Wrapping<T> {}
unsafe impl<T: Zeroable> Zeroable for core::cmp::Reverse<T> {} unsafe impl<T: Zeroable> Zeroable for core::cmp::Reverse<T> {}