3 ms·
The new proposal gives three different types of closures, either immutable, mutable, or call-once. For each type of closure, variables can be either borrowed by
by keeperofdakeys 12y ago
The new proposal gives three different types of closures, either immutable, mutable, or call-once. For each type of closure, variables can be either borrowed by reference, or moved into the closure. This gives six types of possible closures with this proposal. Currently, only two out of those six are supported (The current ||, and proc). So this proposal means closures are more powerful, and that two different, inconsistent types of closures can be unified.
While the internals are probably going to stay the same (the traits), syntax sugar is still very much being thought about.
- kibwen 12y agoKeep in mind that that we expect that the "six types of possible closures" can be almost completely inferred at the use site, so people making use of APIs that accept closures should be able to be blissfully unaware of this distinction. Library authors will need to keep in mind the distinction between the three different closure traits when writing function signatures, but this is no different from how every other borrowed and owned thing in Rust works.