I understand why type inference for module-level constants is not permitted (the same reason why type inference is not permitted for functions). However, why exactly does Rust not permit type inference for local constants?
fn main() {
const N = 1; // error: expected `:`, found `=`
let n = 1; // OK
}
Is there a more profound reason than consistency?
Insofar as I'm aware, there's no distinction between a const
inside a function and one outside. They're both the same thing, so they follow the same rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With