|
|
|
|
|
by masklinn
115 days ago
|
|
Unions can be used as a somewhat safer (not safe by any means but safer), more flexible, and less error-prone form of transmute. Notably you can use unions to transmute between a large type and a smaller type. That is essentially the motivation, primarily in the context of FFI where matching C's union behaviour using transmute is tricky and error-prone. |
|
Also you can manually tag them and get s.th. more like other high level languages. It will just look ugly.