rust-num/num-complex

Safe transmuting for `Complex<T>` with `bytemuck`

bradleyharden opened this issue · 2 comments

I think this request is unlikely to be accepted, but I thought I would at least ask.

I recently ran into an issue using Complex<T> with types from the fixed crate and bytemuck. fixed implements Pod, for all of its types, so they are safely transmutable to [u8] slices. Unfortunately, once I use Complex, I can no longer use bytemuck, even though Complex would satisfy the unsafe requirements of Pod.

I was wondering if it would be possible to add bytemuck as an optional dependency, with an implementation of Pod for Complex<T> where T: Pod. bytemuck seems to be stable and the de facto standard crate for safe transmuting.

I think this would also address the request in rust-num/num#408.

was wondering if it would be possible to add bytemuck as an optional dependency, with an implementation of Pod for Complex<T> where T: Pod. bytemuck seems to be stable and the de facto standard crate for safe transmuting.

I'm fine with this, preferably as manual impls rather than derives to keep the dependencies down. It will need both Pod and Zeroable, but they should be easy enough.

Ok great. I can make a PR