Fix Rust problems using references in closures.