macroquad icon indicating copy to clipboard operation
macroquad copied to clipboard

Make the ToBytes trait unsafe

Open meithecatte opened this issue 8 months ago • 1 comments

Because of the ToBytes impls on arrays and slices, which do not make use of to_bytes of the underlying type, implementing ToBytes makes a promise to unsafe code. This should be explicit, by having the trait itself be unsafe.

Also replaces the impl for &[T] with one for [T], to avoid depending on the layout of &[T]. This is, technically, a breaking change – however, the code that would break didn't actually work at runtime in the first place.

meithecatte avatar Apr 23 '25 03:04 meithecatte

In your opinion, how public should this trait actually be? I looked through the library, and this trait is only used in the set_uniform functions. Maybe it should just be made unavailable for external implementation?

KurlykovDanila avatar May 22 '25 08:05 KurlykovDanila