3 ms·
There are some eye-poking bits in Rust's syntax, but this one is not so bad. `Ok(value)` makes an instance of the `Result` type. Imagine `struct Result Ok(some
by pornel 10y ago
There are some eye-poking bits in Rust's syntax, but this one is not so bad.
`Ok(value)` makes an instance of the `Result` type. Imagine `struct Result Ok(some_t value);` in C.
`()` is a 0-length case of a tuple. Sort-of like `{}` in C's `int arr[] = {}`.
It's used here, because `Ok` is defined to take a value, so something must be provided. The compiler knows how to optimize out `()` completely, so the single `Result` type can be used for efficiently handling both cases returning a something||error and NULL||error.