More precise borrows in closures

This is a well-written blog entry by @nikomatsakis that shows how to avoid “borrowing too much” in closures and ending up with borrowck conflicts. This is a theme that comes up fairly often in this forum and some folks will find this useful.


The “block-enclosed-closure” (let’s abbreviate to BEC) approach works well and the blog post contains information that I find quite useful.
Still, I do hope that in the longer-term borrowck can make this unnecessary.

I first encountered something similar here:

The blog linked above is well written with a lot better description of what’s going on.