1 | use super::*;
|
2 |
|
3 | // Note(Lokathor): This is the neat part!!
|
4 | unsafe impl<T: PodInOption> Pod for Option<T> {}
|
5 |
|
6 | /// Trait for types which are [Pod](Pod) when wrapped in
|
7 | /// [Option](core::option::Option).
|
8 | ///
|
9 | /// ## Safety
|
10 | ///
|
11 | /// * `Option<T>` must uphold the same invariants as [Pod](Pod).
|
12 | /// * **Reminder:** pointers are **not** pod! **Do not** mix this trait with a
|
13 | /// newtype over [NonNull](core::ptr::NonNull).
|
14 | pub unsafe trait PodInOption: ZeroableInOption + Copy + 'static {}
|
15 |
|
16 | unsafe impl PodInOption for NonZeroI8 {}
|
17 | unsafe impl PodInOption for NonZeroI16 {}
|
18 | unsafe impl PodInOption for NonZeroI32 {}
|
19 | unsafe impl PodInOption for NonZeroI64 {}
|
20 | unsafe impl PodInOption for NonZeroI128 {}
|
21 | unsafe impl PodInOption for NonZeroIsize {}
|
22 | unsafe impl PodInOption for NonZeroU8 {}
|
23 | unsafe impl PodInOption for NonZeroU16 {}
|
24 | unsafe impl PodInOption for NonZeroU32 {}
|
25 | unsafe impl PodInOption for NonZeroU64 {}
|
26 | unsafe impl PodInOption for NonZeroU128 {}
|
27 | unsafe impl PodInOption for NonZeroUsize {}
|
28 | |