2 ms·
You get a compile time failure. There is no mechanism to automatically update them.
by steveklabnik 2y ago
You get a compile time failure. There is no mechanism to automatically update them.
- sesm 2y agoOk, I see now. This is limited to cases when compiler can prove that the reference is not shared, but still can be useful when adding elements to collections.
- steveklabnik 2y agoYeah, among other things. It can be used to implement “session types” which basically means encoding a state machine in the type system. So for example, I’m building a web application at work, and users have permissions to access resources. The “please grab a foo from the database” function takes an Authorization as a parameter by move, so in order to call it I have to get one. The only way to get one is to ask the auth subsystem, which checks if a User has the proper permissions. And the only way to get a User is to ask the auth system to authenticate that they have a valid session. So as long as I make my “fetch resources” code require an Authorization as a parameter in the future, I’ll also guarantee that all of the rest of that stuff happens. It’s a little verbose but pretty cool.