Skip to content

Commit

Permalink
Support Zeroable and Pod for f16 and f128 (#251)
Browse files Browse the repository at this point in the history
These are gated under a new feature flag `nightly_float`.

Fixes: <#250>
  • Loading branch information
tgross35 authored Jun 19, 2024
1 parent d15b8e0 commit 9b81537
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Pod> Pod for Wrapping<T> {}

#[cfg(feature = "unsound_ptr_pod_impl")]
Expand Down
4 changes: 4 additions & 0 deletions src/zeroable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ unsafe impl Zeroable for usize {}
unsafe impl Zeroable for isize {}
unsafe impl Zeroable for u128 {}
unsafe impl Zeroable for i128 {}
#[cfg(feature = "nightly_float")]
unsafe impl Zeroable for f16 {}
unsafe impl Zeroable for f32 {}
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 core::cmp::Reverse<T> {}

Expand Down

0 comments on commit 9b81537

Please sign in to comment.