diff --git a/Cargo.toml b/Cargo.toml index e2a233c..a014cf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,9 @@ unsound_ptr_pod_impl = [] # MSRV 1.46.0: adds the `#[track_caller]` attribute to functions which may panic track_caller = [] +# MSRV 1.74.0 Pod/Zeroable implementations for `core::num::Saturating` +pod_saturating = [] + # Enables all features that are both sound and supported on the latest stable # version of Rust, with the exception of `extern_crate_alloc` and # `extern_crate_std`. @@ -73,6 +76,7 @@ latest_stable_rust = [ "min_const_generics", "must_cast", "must_cast_extra", + "pod_saturating", "track_caller", "transparentwrapper_extra", "wasm_simd", diff --git a/src/lib.rs b/src/lib.rs index 592b910..44eef76 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,6 +82,7 @@ //! Box and Vec. //! * `zeroable_maybe_uninit` and `zeroable_atomics`: Provide more [`Zeroable`] //! impls. +//! * `pod_saturating`: Provide more [`Pod`] and [`Zeroable`] impls. //! * `wasm_simd` and `aarch64_simd`: Support more SIMD types. //! * `min_const_generics`: Provides appropriate impls for arrays of all lengths //! instead of just for a select list of array lengths. diff --git a/src/pod.rs b/src/pod.rs index 7d17ff9..ae1437c 100644 --- a/src/pod.rs +++ b/src/pod.rs @@ -57,6 +57,9 @@ unsafe impl Pod for f64 {} unsafe impl Pod for f128 {} unsafe impl Pod for Wrapping {} +#[cfg(feature = "pod_saturating")] +unsafe impl Pod for core::num::Saturating{} + #[cfg(feature = "unsound_ptr_pod_impl")] #[cfg_attr( feature = "nightly_docs", diff --git a/src/zeroable.rs b/src/zeroable.rs index bfbb26c..0a2cdaa 100644 --- a/src/zeroable.rs +++ b/src/zeroable.rs @@ -56,6 +56,8 @@ unsafe impl Zeroable for f64 {} unsafe impl Zeroable for f128 {} unsafe impl Zeroable for Wrapping {} unsafe impl Zeroable for core::cmp::Reverse {} +#[cfg(feature = "pod_saturating")] +unsafe impl Zeroable for core::num::Saturating {} // Note: we can't implement this for all `T: ?Sized` types because it would // create NULL pointers for vtables.