4 ms·
Good point, I was thinking of cloning the closure itself, not capturing Arcs and having to clone them to avoid moves. Though in this case it would be C++'s impl
by eridius 8y ago
Good point, I was thinking of cloning the closure itself, not capturing Arcs and having to clone them to avoid moves. Though in this case it would be C++'s implicit copies rather than capture clauses.
In terms of capture clauses, what I really like are Swift's, as they allow you to bind identifiers to expressions in the capture clause itself (as opposed to just doing capture-by-value vs capture-by-reference). Having capture clauses in Rust that have the same capability would be great.
- pcwalton 8y agoRust used to have capture clauses, but they were removed in order to reduce the complexity of the language. It might make sense to add them back later, but given that Rust is still constantly criticized for being too complex I think it's probably still not yet time.
- masklinn 8y agoThat makes sense to me, I subscribe to the view that software "design patterns" are userland patches for things missing from the language or misuses thereof. The question is then whether the feature is missing enough (the pattern is common) that it makes sense to feed it back into built-in support or not. I don't know how common the knowledge of nikomatsakis's pattern is though, and thus if crates could be automatically searched for it.