]> git.lizzy.rs Git - rust.git/blob - src/test/ui/swap-2.rs
Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
[rust.git] / src / test / ui / swap-2.rs
1 // run-pass
2
3 use std::mem::swap;
4
5 pub fn main() {
6     let mut a: Vec<isize> = vec![0, 1, 2, 3, 4, 5, 6];
7     a.swap(2, 4);
8     assert_eq!(a[2], 4);
9     assert_eq!(a[4], 2);
10     let mut n = 42;
11     swap(&mut n, &mut a[0]);
12     assert_eq!(a[0], 42);
13     assert_eq!(n, 0);
14 }