Skip to content

Commit ee2f71f

Browse files
authored
Add pod_saturating feature (#303)
1 parent e023695 commit ee2f71f

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ unsound_ptr_pod_impl = []
5858
# MSRV 1.46.0: adds the `#[track_caller]` attribute to functions which may panic
5959
track_caller = []
6060

61+
# MSRV 1.74.0 Pod/Zeroable implementations for `core::num::Saturating`
62+
pod_saturating = []
63+
6164
# Enables all features that are both sound and supported on the latest stable
6265
# version of Rust, with the exception of `extern_crate_alloc` and
6366
# `extern_crate_std`.
@@ -73,6 +76,7 @@ latest_stable_rust = [
7376
"min_const_generics",
7477
"must_cast",
7578
"must_cast_extra",
79+
"pod_saturating",
7680
"track_caller",
7781
"transparentwrapper_extra",
7882
"wasm_simd",

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
//! Box and Vec.
8383
//! * `zeroable_maybe_uninit` and `zeroable_atomics`: Provide more [`Zeroable`]
8484
//! impls.
85+
//! * `pod_saturating`: Provide more [`Pod`] and [`Zeroable`] impls.
8586
//! * `wasm_simd` and `aarch64_simd`: Support more SIMD types.
8687
//! * `min_const_generics`: Provides appropriate impls for arrays of all lengths
8788
//! instead of just for a select list of array lengths.

src/pod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ unsafe impl Pod for f64 {}
5757
unsafe impl Pod for f128 {}
5858
unsafe impl<T: Pod> Pod for Wrapping<T> {}
5959

60+
#[cfg(feature = "pod_saturating")]
61+
unsafe impl<T: Pod> Pod for core::num::Saturating<T>{}
62+
6063
#[cfg(feature = "unsound_ptr_pod_impl")]
6164
#[cfg_attr(
6265
feature = "nightly_docs",

src/zeroable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ unsafe impl Zeroable for f64 {}
5656
unsafe impl Zeroable for f128 {}
5757
unsafe impl<T: Zeroable> Zeroable for Wrapping<T> {}
5858
unsafe impl<T: Zeroable> Zeroable for core::cmp::Reverse<T> {}
59+
#[cfg(feature = "pod_saturating")]
60+
unsafe impl<T: Zeroable> Zeroable for core::num::Saturating<T> {}
5961

6062
// Note: we can't implement this for all `T: ?Sized` types because it would
6163
// create NULL pointers for vtables.

0 commit comments

Comments
 (0)