3 ms·
This example is one of those things I keep running into though, and don't fully understand: why does type inference not work on consts? e.g., here, why can't we
by deathanatos 9y ago
This example is one of those things I keep running into though, and don't fully understand: why does type inference not work on consts? e.g., here, why can't we drop the entire type:
const USAGE = "usage: blah blah";
The RHS has sufficient type information, does it not? After all, if this were a let USAGE = ... inside a function, that would be sufficient.
(I don't find this particular bit a deal-breaker though; thus far, I quite like Rust.)
- steveklabnik 9y agoThis was an explicit decision; we could do this kind of inference but chose not to, similar to how you must declare the types of functions. We started with the most conservative choice, and then are feeling it out; that's why you can now drop the lifetime.