2 ms·
You can do all sorts of C things in Rust, and they're merely not idiomatic. For example your Rust function that always returns 42 should probably be: const
by tialaramex 5y ago
You can do all sorts of C things in Rust, and they're merely not idiomatic.
For example your Rust function that always returns 42 should probably be:
const fn fortytwo() -> i32 {
42
}
But C programmers might try:
const fn fortytwo() -> i32 {
return 42;
}
And that works fine, the compiler sees that you wanted to return 42 here, and, although the value at the tail of the function is an empty tuple and thus incompatible with your function signature you never reach that tail, so no problem.