2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2014-03-05 17:28:08 -06:00
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
fn swap<F>(f: F) -> Vec<isize> where F: FnOnce(Vec<isize>) -> Vec<isize> {
|
2016-10-29 16:54:04 -05:00
|
|
|
let x = vec![1, 2, 3];
|
2013-07-17 18:58:43 -05:00
|
|
|
f(x)
|
|
|
|
}
|
|
|
|
|
2013-09-25 02:43:37 -05:00
|
|
|
pub fn main() {
|
2013-07-17 18:58:43 -05:00
|
|
|
let v = swap(|mut x| { x.push(4); x });
|
2013-11-21 19:23:21 -06:00
|
|
|
let w = swap(|mut x| { x.push(4); x });
|
2013-07-17 18:58:43 -05:00
|
|
|
assert_eq!(v, w);
|
|
|
|
}
|