Skip to content

[Rust] custom derive for struct/enum with resource types #1467

@chenyan2002

Description

@chenyan2002

Currently custom derive applies to all struct and enum definitions. Understandably, the resource struct doesn't use the custom derive. The problem is that when the struct/enum type contains a resource type, the derive trait will not work. We can use additional-derive-ignore to opt-out such types individually, but that's not very convenient.

I can see several ways to fix it, but not sure which one makes more sense:

  1. Only apply custom derive to struct and enum that doesn't contain resource types. This is equivalent to manually opt-out those types with additional-derive-ignore.
  2. Apply the custom derive to resource struct as well. But many traits don't make sense for resource types.
  3. Have a flag to define custom derive for individual types, similar to with, we can have a with-derive.

Maybe in the short term, we can apply the first option, which is also easy to implement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    gen-rustRelated to bindings for Rust-compiled-to-WebAssembly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions