Created
May 29, 2022 01:00
-
-
Save leroycep/e36a01d8a5ed9617fbc0ef6d84f82b1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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