RustCrypto / hybrid-array

Hybrid typenum/const generic arrays
Apache License 2.0
9 stars 8 forks source link

Optional bytemuck support #83

Closed edgarogh closed 3 weeks ago

edgarogh commented 3 months ago

bytemuck allows safe transmuting of simple types with no uninhabited values. I would be really useful if hybrid-array implemented it the same way bytemuck implements it on native constant-sized arrays. Obviously, the dependency would be optional.

How ?

This is the impl for the standard generic array, it should be trivial to adapt:

unsafe impl<T, const N: usize> Pod for [T; N] where T: Pod {}

source: https://github.com/Lokathor/bytemuck/blob/005ee3254fdfa63d67d024cfc598319331dab0cb/src/pod.rs#L87

Why ?

Why not ?

tarcieri commented 3 months ago

I'd be okay with adding it as an optional dependency