kornelski / rust-rgb

struct RGB for sharing pixels between crates
https://lib.rs/rgb
MIT License
98 stars 19 forks source link

Remove the `ComponentBytes` and `AsPixels` traits #70

Closed ripytide closed 2 months ago

ripytide commented 3 months ago

I don't see the utility of the ComponentBytes and AsPixels traits compared to a user simply using bytemuck's cast_slice() and cast_slice_mut() methods. This could easily be achieved by optionally implementing bytemuck::Pod for all the pixel structs. Then a user could enable that crate-feature and use bytemuck to do conversions as they need.

In addition, having an crate-local implementation has had soundness flaws in the past in #35 so removing it would reduce that risk.

ripytide commented 3 months ago

Also mentioned in https://github.com/kornelski/rust-rgb/issues/39#issuecomment-835298062

kornelski commented 2 months ago

The only issue is that bytemuck's syntax is more verbose, since cast_slice() etc are not trait methods, but standalone functions in the bytemuck crate.