Re:Linux Rust Support
by tialaramex on Tuesday July 06, 2021 @12:56PM
(#27751187)
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.
For example your Rust function that always returns 42 should probably be:
But C programmers might try: 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.