I completely agree, but the point was to show Rust code that does the same thing as the (equally unsafe) C++ code, and particularly that it doesn't treat built-ins any different than other types. But nobody should be writing code like this in either language.
To me the whole point of an "uninitialized variable" is to declare it in one place and then assign it in exactly one code path, which is exactly what rust supports without any unsafe code:
let i: i32;
if is_tuesday {
i = 0;
else {
i = 1;
}
foo(i);
is already perfectly valid, safe rust code, because the compiler knows that all code paths result in assignment before use. And the answer to "what happens on that first line?" is "nothing", because it's just a declaration. In the equivalent C++ you'd be running an arbitrary constructor on the first line, and hoping the compiler optimizes it away. Or if the default constructor doesn't exist or is deleted, you simply can't code that way.