Commit 504dcd1
authored
Disallow the value 0 in
The canonical ABI for its part [guarantees] the value 0 will not be used
as a table index. Should users of the Rust bindings be able to construct
handle types with the value 0?
If we say yes, then handle types act as if they have an internal `Option`
type that gets implicitly unwrapped when passed to an import.
However, in this PR I propose to say no, and prohibit zero in handle types.
It seems tidier to say that code depending on optionality should explicitly
use `Option` for itself, which will then help avoid traping, by
construction. And even if we can't do niche optimizations today due to the
`AtomicU32`, it is theoretically possible we could do something with
`NonZeroU32` in the future.
[guarantees]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#table-statefrom_handle methods in the Rust bindings. (#1318)1 parent a9d8e9a commit 504dcd1
2 files changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
667 | | - | |
| 667 | + | |
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
| |||
0 commit comments