Re: [PATCH 04/13] Kbuild: Rust support

From: Miguel Ojeda
Date: Fri Apr 16 2021 - 17:22:22 EST


On Fri, Apr 16, 2021 at 10:22 PM Willy Tarreau <w@xxxxxx> wrote:
>
> So it simply does the equivalent of:
>
> struct result {
> int status;
> int error;
> };

Not exactly, it is more like a tagged union, as Connor mentioned.

However, and this is the critical bit: it is a compile-time error to
access the inactive variants (in safe code). In C, it is on you to
keep track which one is the current one.

> kill_foo(); // only for rust, C doesn't need it

Please note that `kill_foo()` is not needed in Rust -- it was an
example of possible cleanup (since Al mentioned resources/cleanup)
using RAII.

Cheers,
Miguel