linebender / color

Color in Rust.
Apache License 2.0
39 stars 5 forks source link

Improve interop with `bytemuck` and FFI. #43

Closed waywardmonkeys closed 2 weeks ago

waywardmonkeys commented 2 weeks ago

AlphaColor, OpaqueColor, and PremulColor are now using #[repr(transparent)] and impl the bytemuck traits Pod, TransparentWrapper, and Zeroable.

Rgba8 is now #[repr(C)] and impls the bytemuck traits Pod and Zeroable.

The bytemuck traits are only available when the new bytemuck feature is enabled. It is not enabled by default.

This requires relaxing the forbidding of unsafe_code as the impls of the bytemuck traits must use unsafe impl.

raphlinus commented 2 weeks ago

Do you also need to implement the TransparentWrapper trait to be strictly conforming with bytemuck's expecations?

waywardmonkeys commented 2 weeks ago

Do you also need to implement the TransparentWrapper trait to be strictly conforming with bytemuck's expecations?

I did when I switched to repr(transparent).