-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add as_xyz
helper methods to Smithy unions / Rust enums
#298
Comments
get_xyz
helper methods to unionsas_xyz
helper methods to unions
as_xyz
helper methods to unionsas_xyz
helper methods to Smithy unions / Rust enums
Would like to jump on this. As a newbie with Rust and this project, this would be a good start to look through the code. |
Hey, what would be the preferred approach between the following two:
To detail more about option 1, I was thinking of something like generating the following Rust code for unions: #[derive(MemberConvertible)]
pub enum SomeUnion {
Foo(Foo),
Bar(Bar),
} where this What do you think? |
In general, I would favor generating impl functions in Kotlin. Since we're code generating everything anyway, there isn't a compelling reason to build a derive macro. Adding a derive macro is what a "regular" Rust project would probably do but it introduces a bunch of extra complexity |
Cool, then I will go with option 2. I'll submit a PR by tomorrow. |
* Add as_xyz and is_xyz helper methods on Smithy Unions Issue #298 * Fix Unions generation and add unit test Co-authored-by: Victor Barbu <vicbarbu@amazon.com>
[reopened to also track adding the same thing to enums] |
Each union variant will define a
as_xyz() -> Option<&Xyz>
andis_xyz() -> bool
method to enable easily extracting individual variants from the union without matching.These should also be added to top level & combined errors.
The text was updated successfully, but these errors were encountered: