bytecodealliance / bytecodealliance/wit-bindgen

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

Open
#1,467 1 comment 0 reactions 0 assignees View on GitHub
gen-rust
Dominant language
Rust
Stars
1.5k
Forks
286
Avg merge
6h 32m
Merged PRs (30d)
19

Description

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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.