snuk182 / nuklear-rust

The bindings to the Nuklear 2D immediate GUI library.
Apache License 2.0
359 stars 16 forks source link

Use repr(transparent) for wrapper structs #32

Open LoganDark opened 4 years ago

LoganDark commented 4 years ago

repr(transparent) provides stronger guarantees that the struct will have the exact same representation as its only field. And Context didn't even have an explicit representation, not even repr(C)!!

Because of all the transmutation that this library does between wrapper types and the types that they wrap, those guarantees are quite important, don't you think? :)

LoganDark commented 4 years ago

Upon closer inspection it does look like Context does not need repr(transparent) since the library doesn't implement AsRef and such for it, but this is still a way to strengthen the safety of the wrapper types.