lkml.org 
[lkml]   [2021]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 04/13] Kbuild: Rust support
From
Date
On 4/16/21 3:22 PM, Willy Tarreau wrote:
> So it simply does the equivalent of:
>
> #define EINVAL -1234
>
> struct result {
> int status;
> int error;
> };

Result and Option types are more like a union with a tag that
describes which variant it is.

struct foo_result {
/* if ok, then access foo_or_err.successful_foo
* else, access foo_or_err.error
*/
bool ok;
union {
struct foo successful_foo;
int error;
} foo_or_err;
};

> [..]
>
> So it simply returns a pair of values instead of a single one, which

It will only return 1 value.

\
 
 \ /
  Last update: 2021-04-16 22:35    [W:0.346 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site