Use &mut closure to satisfy the borrow checker

Fixes broken build on rust HEAD. See https://github.com/mozilla/rust/pull/13686 for more details.