3 ms·
That Rust syntax (I see on the SQLx page) is really appalling. What's "Ok(())" supposed to mean and why are there two pairs of braces. There almost nothing imme
by ofrzeta 5y ago
That Rust syntax (I see on the SQLx page) is really appalling. What's "Ok(())" supposed to mean and why are there two pairs of braces. There almost nothing immediately comprehensible and what's comprehensible seems overly complicated: "let row: (i64,)" - what's with that trailing comma here?
- CodesInChaos 5y agoA `Result<T, Error>` can either be `Ok(value)` or `Error(value)` where value must be of type `T` or `Error` respectively. If you don't want to carry any information you use the unit type `()`, which has a single value `()`. So in `Ok(())` the outer parentheses are for constructing the OK result, while the inner parentheses are the unit value. `(i64,)` is a tuple with a single component, the trailing comma disambiguates it from plain parentheses. I haven't needed one of those so far.