3 ms·
Not a rust user. Could const be inferred instead of needing to be explicit? At least, hypothetically?
by nwah1 6y ago
Not a rust user. Could const be inferred instead of needing to be explicit? At least, hypothetically?
- steveklabnik 6y agoIn theory, yes. In practice, it is an API commitment, and so it is not inferred, because you as a library author have to decide if you want to commit to it or not.
- nwah1 6y agoMaybe for stuff that never can be externally accessed, const should be inferred as an optimization pass.
- steveklabnik 6y agoYes, this is already done. But that's not the more interesting part of the feature. Once you require something to be const, you can use it in contexts that require something to be const. Inferring it in non-const contexts is less powerful.