Skip to main content

enum_map/
bytemuck.rs

1// SPDX-FileCopyrightText: 2024 +merlan #flirora <uruwi@protonmail.com>
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5use bytemuck::{Pod, TransparentWrapper, Zeroable};
6
7use crate::{Enum, EnumMap};
8
9// SAFETY: `EnumMap<K, V>` is a transparent wrapper around `K::Array<V>`, so
10// any layout property that applies to `K::Array<V>` also applies to
11// `EnumMap<K, V>`.
12
13unsafe impl<K: Enum + 'static, V: 'static> Pod for EnumMap<K, V> where K::Array<V>: Pod {}
14
15unsafe impl<K: Enum, V> TransparentWrapper<K::Array<V>> for EnumMap<K, V> {}
16
17unsafe impl<K: Enum, V> Zeroable for EnumMap<K, V> where K::Array<V>: Zeroable {}