Skip to content

Make the ToBytes trait unsafe #956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meithecatte
Copy link

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.

@KurlykovDanila
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants