1 // run-pass 2 // Test that in a by-ref once closure we move some variables even as 3 // we capture others by mutable reference. 4 call<F>(f: F) where F : FnOnce()5fn call<F>(f: F) where F : FnOnce() { 6 f(); 7 } 8 main()9fn main() { 10 let mut x = vec![format!("Hello")]; 11 let y = vec![format!("World")]; 12 call(|| { 13 // Here: `x` must be captured with a mutable reference in 14 // order for us to append on it, and `y` must be captured by 15 // value. 16 for item in y { 17 x.push(item); 18 } 19 }); 20 assert_eq!(x.len(), 2); 21 assert_eq!(&*x[0], "Hello"); 22 assert_eq!(&*x[1], "World"); 23 } 24