News for hackers. Stuff that matters.
Re:Announcing Rust 1.19 by Manishearth on Thursday July 20, 2017 @02:39PM (#14815173)
FWIW the hacked up workaround that bindgen uses is _beautiful_

https://github.com/servo/rust-bindgen/blob/master/tests/expe...

Basically, if you have a union of A, B, C, you create a struct with three zero-sized fields using BindgenUnionField<A>, and then add a field after that containing enough bits to actually fill out the size. Because the BindgenUnionField is zero sized, a pointer to it is a pointer to the beginning of the struct, and it has an accessor that treats the pointer as the contained type.

This makes the API for field access `union.field.as_ref()` instead of `union.field`, but that's still pretty clean.

It's still a hack, and I'll be happy to see it go, but it's a really fun hack.

Re:Announcing Rust 1.19 by kibwen on Thursday July 20, 2017 @04:39PM (#14816089)
If only English already had a word for "beautiful, yet reprehensible". :)
Re:Announcing Rust 1.19 by fanf2 on Thursday July 20, 2017 @09:01PM (#14817380)
Well "awful" etymologically means "inspiring awe"...
Re:Announcing Rust 1.19 by zem on Thursday July 20, 2017 @04:52PM (#14816190)
sirenlike
Re:Announcing Rust 1.19 by tomsthumb on Thursday July 20, 2017 @06:21PM (#14816765)
You know this word in another language?
Re:Announcing Rust 1.19 by andrewflnr on Friday July 21, 2017 @01:18AM (#14818238)
There must be one in German. :)
Re:Announcing Rust 1.19 by euyyn on Friday July 21, 2017 @12:00PM (#14821543)
Probably just the concatenation, like beautifulyetreprehensible.
Re:Announcing Rust 1.19 by Retra on Thursday July 20, 2017 @09:38PM (#14817499)
>Because the BindgenUnionField is zero sized, a pointer to it is a pointer to the beginning of the struct

Is that a stable assumption?

Re:Announcing Rust 1.19 by Manishearth on Friday July 21, 2017 @01:51AM (#14818354)
Because it's repr(C) IIRC yes.