Messages in this thread | | | From | Miguel Ojeda <> | Date | Fri, 16 Apr 2021 23:19:18 +0200 | Subject | Re: [PATCH 04/13] Kbuild: Rust support |
| |
On Fri, Apr 16, 2021 at 10:22 PM Willy Tarreau <w@1wt.eu> 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
| |