From 3615dfca66920973e9b8e10f6b4b4d2d88df00ed Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 18 Jun 2024 22:18:21 -0500 Subject: [PATCH] Support `Zeroable` and `Pod` for `f16` and `f128` These are gated under a new feature flag `nightly_float`. Fixes: --- Cargo.toml | 2 ++ src/lib.rs | 1 + src/pod.rs | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 05a2715..bfa5d8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,8 @@ unsound_ptr_pod_impl = [] # NOT SEMVER SUPPORTED! TEMPORARY ONLY! nightly_portable_simd = [] nightly_stdsimd = [] +# Enable `f16` and `f128` +nightly_float = [] # Improved documentation using the nightly toolchain nightly_docs = [] diff --git a/src/lib.rs b/src/lib.rs index daa8177..1526587 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ #![allow(clippy::type_complexity)] #![cfg_attr(feature = "nightly_docs", feature(doc_cfg))] #![cfg_attr(feature = "nightly_portable_simd", feature(portable_simd))] +#![cfg_attr(feature = "nightly_float", feature(f16, f128))] #![cfg_attr( all( feature = "nightly_stdsimd", diff --git a/src/pod.rs b/src/pod.rs index 724c0a0..92747a1 100644 --- a/src/pod.rs +++ b/src/pod.rs @@ -49,8 +49,12 @@ unsafe impl Pod for usize {} unsafe impl Pod for isize {} unsafe impl Pod for u128 {} unsafe impl Pod for i128 {} +#[cfg(feature = "nightly_float")] +unsafe impl Pod for f16 {} unsafe impl Pod for f32 {} unsafe impl Pod for f64 {} +#[cfg(feature = "nightly_float")] +unsafe impl Pod for f128 {} unsafe impl Pod for Wrapping {} #[cfg(feature = "unsound_ptr_pod_impl")]