3 ms·
> Some types have no suitable "empty" value. It is dangerous to assume you can always find such a value. Indeed. In Rust you have Option::unwrap_or_default() f
by nybble41 4y ago
> Some types have no suitable "empty" value. It is dangerous to assume you can always find such a value.
Indeed. In Rust you have Option::unwrap_or_default() for this, which is only available if the underlying type implements the Default trait. It's unfortunately more verbose than `?` but it gives the behavior the GP wants, without making unsafe assumptions like 0 always being a safe default for any integer result.