bytecodealliance / bytecodealliance/wit-bindgen

rust: trivial changes to wit definition alters the API of the generated code in an incompatible way

Open
#775 2 comments 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

for example,
```
package foo:bar;

interface hoge {
variant v1 {
a(u32),
}
set1: func(v: v1);
get1: func() -> v1;

variant v2 {
a(u32),
b(string),
}
set2: func(v: v2);
get2: func() -> v2;
}

world useless {
import hoge;
}
```

given the above wit definition, `wit-bindgen rust a.wit` generates functions like:
```rust
pub fn set1(v: V1,){
```
```rust
pub fn set2(v: &V2,){
```

it's a bit surprising to me they are incompatible.
IMO, it's better to keep the same API for trivial changes like this.
i suspect it's simpler for users to use the generated code if you always use borrowed parameters for compound types like variant/record/etc for example.

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.