Skip to content

Conversation

@ericszentivanyi
Copy link
Contributor

@ericszentivanyi ericszentivanyi commented Jan 1, 2026

This PR introduces an or-pattern syntax, allowing the same patch to be applied to multiple generated types.

Example

import_types!(
  schema = "../schema.json",
  patches = {
    Foo | Bar = {
      derives = [/* ... */],
    },
  },
);

Copy link
Collaborator

@ahl ahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work if rename is specified?

@ericszentivanyi
Copy link
Contributor Author

ericszentivanyi commented Jan 8, 2026

How would this work if rename is specified?

Good question. This would require a simple restriction preventing patches that use the or-pattern from specifying renames when applied to multiple types. I used PatchType as the foundation for implementing variant patches (via a PatchType::Path variant), so rename is still supported for variants, but not when applied to types.

Similarly, variant patches should not be able to specify derives, so I added a restriction for that as well. Let me know if you would like me to implement something similar.

@ahl
Copy link
Collaborator

ahl commented Jan 11, 2026

So the use case here is that you have a bit chunk of the generated types for which you want an additional derive macro applied? Many, but not all?

@ericszentivanyi
Copy link
Contributor Author

So the use case here is that you have a bit chunk of the generated types for which you want an additional derive macro applied? Many, but not all?

Yes, some macros (e.g. wasm_bindgen) do not support certain data types, so they would need to be applied via a patch, and it would be useful if this patch were not duplicated.

That is my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants