Stream: general

Topic: ✔ Unit type `_` no longer valid


view this post on Zulip Ari Seyhun (May 07 2022 at 11:49):

An old project of mine had a function defined, which had a return type of expected<_, error>. _ used to correlate to Rust unit type (), but it seems like it's no longer valid.

What type should I use for Rust's () unit type?

view this post on Zulip Ari Seyhun (May 07 2022 at 11:53):

Looking at the wit spec, it seems like expected<_, error> should be valid?
The spec shows:

expected ::= 'expected' '<' expected-ty ',' expected-ty '>'
expected-ty ::= '_'
              | ty

view this post on Zulip Ari Seyhun (May 07 2022 at 11:54):

Oh it seems like tuple<> might be the correct approach now

view this post on Zulip Notification Bot (May 07 2022 at 14:22):

Ari Seyhun has marked this topic as resolved.

view this post on Zulip Peter Huene (May 08 2022 at 22:53):

With the latest in main, unit is now the unit type, so expected<unit, error> should be used instead.

view this post on Zulip Peter Huene (May 08 2022 at 22:55):

unit might be replaced with () like in Rust, discussion is here: https://github.com/bytecodealliance/wit-bindgen/issues/217

view this post on Zulip Peter Huene (May 08 2022 at 22:56):

on a related note, tuple might also be replaced with (...) like in Rust, discussion here: https://github.com/bytecodealliance/wit-bindgen/issues/216

Right now the syntax for tuples is tuple<A, B, C>, but the only reason for this was to disambiguate the multi-value returns we originally had which had the shape -> (A, B, C). It's pro...

Last updated: Nov 22 2024 at 16:03 UTC