-
Notifications
You must be signed in to change notification settings - Fork 91
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
Configurable Generic Constraints for Swift #95
Conversation
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.
Looks good so far, needs further tests as mentioned.
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.
The default typeshare.toml specification worked, but if I didn't specify it there, and tried to apply it to a single type, it did nothing. For example:
#[typeshare(swift(generic_decorators = "Sendable & Codable"))]
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct MyMenuEntry<A> {
generated:
public struct MyMenuEntry<A: Codable>: Codable, Sendable
@kevinbhayes I've been trying to fix this - it looks like parenthesized parameters like |
If you want to break that part off into a separate issue, that's ok with me. I think we'll be using the toml definitions anyway. |
@kevinbhayes Okay, I'll split this PR. |
…n for the new container type
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.
Tested by adding Sendable to default_generic_constraints = ["Sendable"]
and it produced MyStruct<A: Codable & Sendable>: Codable
so all is good!
Resolves #86.
Default type constraints can now be specified for Swift within the config, using
default_generic_constraints = [...]
under[swift]
. Constraint strings within the list can include multiple constraints, such asSendable & Identifiable
.