mozilla/rust — pull request #14501 by pcwalton (2014-05-29 01:32:41+00:00)
Title: librustc: Copy or move upvars by value.

Closes #12831.

This breaks many closures (about 10%) that look like this:

let mut sum = 0;
f.map(|x| sum += x);

Instead, rewrite them like this:

let mut sum = 0;
{
let sum_ptr = &mut sum;
f.map(|x| *sum_ptr += x);
}

Or, ideally, switch to RAII- or iterator-like patterns.

[breaking-change]

r? @pnkfelix