Re:Rust: A Critical Retrospective
by wtetzner on Thursday May 19, 2022 @10:23PM
(#31442641)
How does Zig represent Option<Option<i32>>? Would it be something like this?
[ Parent
| on HN ]
I had to try it out first, but yep, that's how it works:
const assert = @import("std").debug.assert;
fn get12() i32 {
const opt_opt_val: ??i32 = 12;
const val = opt_opt_val.?.?;
comptime assert(val == 12);
return val;
}
[https://www.godbolt.org/z/oncd5shvP]