logoalt Hacker News

slopinthebag • yesterday at 9:48 PM • 1 reply • view on HN

i dont understand what rust doesn't give you that zig does?


Replies

Jtsummers • yesterday at 9:53 PM

https://zig.guide/language-basics/unions/ - Seems like it's more similar to Ada's variant records: https://learn.adacore.com/courses/intro-to-ada/chapters/more...

Instead of just getting one type that includes the discriminant and records, Zig and Ada have a tag of some type whose value determines which variant is being used, and then the union (Zig) or record (Ada) is its own type.

➕ show 2 replies