Stream: wit-bindgen

Topic: bounded lists


view this post on Zulip Matthew Yacobucci (Apr 21 2023 at 01:45):

is there a way to create bounded lists?

e.g.)
record {
items list<s32> // limit to 8 elements?
}

view this post on Zulip Dan Gohman (Apr 21 2023 at 01:46):

No, though if you have a use case for it, there's an issue that's collecting them: https://github.com/WebAssembly/component-model/issues/181

Rust has fixed length arrays whose type is written as [u8;32] for a 32-byte array. You can achieve this in the current wit specification by doing tuple<u8,u8 ... u8> (with 32 u8s). Could list<u8,32...

view this post on Zulip Matthew Yacobucci (Apr 21 2023 at 01:49):

Right on, it's not a strong use case, but I'm experimenting using md5 and wanted to limit the buffer to 64 bytes. I'll review the component model issue and perhaps comment.


Last updated: Dec 23 2024 at 12:05 UTC