Re:Rust 1.47
by nwah1 on Thursday October 08, 2020 @09:24PM
(#24725774)
Not a rust user. Could const be inferred instead of needing to be explicit? At least, hypothetically?
[ Parent
| on HN ]
Re:Rust 1.47
by steveklabnik on Thursday October 08, 2020 @10:03PM
(#24725996)
In 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.
Maybe for stuff that never can be externally accessed, const should be inferred as an optimization pass.
Re:Rust 1.47
by steveklabnik on Friday October 09, 2020 @08:38AM
(#24729257)
Yes, 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.