-
Notifications
You must be signed in to change notification settings - Fork 63
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
Support enums with named data #175
Support enums with named data #175
Conversation
Mind surrounding your Rust example in a bridge module? #[swift_bridge::bridge]
mod ffi {
// ...
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. One minor piece of feedback but otherwise looks good to me.
Thanks!
@@ -38,6 +38,20 @@ impl NormalizedStructField { | |||
} | |||
} | |||
|
|||
/// Used when we want to avoid putting spaces at all between the field name and the colon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer to do all of the field setting here instead of doing half of it here an half of it at the call site.
Maybe something like:
/// Create a string for setting the value of a struct's field.
///
/// Example if named field -> "field_name: someValue".
/// Example if unnamed field -> "someValue".
fn struct_field_setter_string(&self, value: String) -> String {
match &self.accessor {
NormalizedStructFieldAccessor::Named(name) => {
format!("{}: {}", name.to_string(), value)
}
NormalizedStructFieldAccessor::Unnamed(_idx) => {
value
}
}
}
Great stuff. Thanks! |
This PR addresses #160 and adds support for enums with named data.
Here's an example of using this.