aboutsummaryrefslogtreecommitdiff
path: root/vendor/bytemuck/src/pod_in_option.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/bytemuck/src/pod_in_option.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/bytemuck/src/pod_in_option.rs')
-rw-r--r--vendor/bytemuck/src/pod_in_option.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/bytemuck/src/pod_in_option.rs b/vendor/bytemuck/src/pod_in_option.rs
new file mode 100644
index 0000000..3327e99
--- /dev/null
+++ b/vendor/bytemuck/src/pod_in_option.rs
@@ -0,0 +1,27 @@
+use super::*;
+
+// Note(Lokathor): This is the neat part!!
+unsafe impl<T: PodInOption> Pod for Option<T> {}
+
+/// Trait for types which are [Pod](Pod) when wrapped in
+/// [Option](core::option::Option).
+///
+/// ## Safety
+///
+/// * `Option<T>` must uphold the same invariants as [Pod](Pod).
+/// * **Reminder:** pointers are **not** pod! **Do not** mix this trait with a
+/// newtype over [NonNull](core::ptr::NonNull).
+pub unsafe trait PodInOption: ZeroableInOption + Copy + 'static {}
+
+unsafe impl PodInOption for NonZeroI8 {}
+unsafe impl PodInOption for NonZeroI16 {}
+unsafe impl PodInOption for NonZeroI32 {}
+unsafe impl PodInOption for NonZeroI64 {}
+unsafe impl PodInOption for NonZeroI128 {}
+unsafe impl PodInOption for NonZeroIsize {}
+unsafe impl PodInOption for NonZeroU8 {}
+unsafe impl PodInOption for NonZeroU16 {}
+unsafe impl PodInOption for NonZeroU32 {}
+unsafe impl PodInOption for NonZeroU64 {}
+unsafe impl PodInOption for NonZeroU128 {}
+unsafe impl PodInOption for NonZeroUsize {}