Skip to content

Instantly share code, notes, and snippets.

@leroycep
Created May 29, 2022 01:00
Show Gist options
  • Save leroycep/e36a01d8a5ed9617fbc0ef6d84f82b1f to your computer and use it in GitHub Desktop.
Save leroycep/e36a01d8a5ed9617fbc0ef6d84f82b1f to your computer and use it in GitHub Desktop.
const Errors = error{
hello,
world,
};
// It's a tagged union, expect the tag is an error set
const ErrorUnion = union(Errors) {
hello: u32,
world: []const u8,
};
// To return an errorset tagged union, you have to construct it
pub fn main() ErrorUnion!void {
return ErrorUnion{
.world = "greetings",
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment