Skip to content

Commit 42271a5

Browse files
committed
Move vec swap test
1 parent 4fd06b9 commit 42271a5

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

library/alloc/tests/vec.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::cell::Cell;
33
use std::collections::TryReserveError::*;
44
use std::fmt::Debug;
55
use std::iter::InPlaceIterable;
6-
use std::mem::size_of;
6+
use std::mem::{size_of, swap};
77
use std::ops::Bound::*;
88
use std::panic::{catch_unwind, AssertUnwindSafe};
99
use std::rc::Rc;
@@ -1942,3 +1942,15 @@ fn test_vec_macro_repeat() {
19421942
let n = 3;
19431943
assert_eq!(vec![el; n], vec![Box::new(1), Box::new(1), Box::new(1)]);
19441944
}
1945+
1946+
#[test]
1947+
fn test_vec_swap() {
1948+
let mut a: Vec<isize> = vec![0, 1, 2, 3, 4, 5, 6];
1949+
a.swap(2, 4);
1950+
assert_eq!(a[2], 4);
1951+
assert_eq!(a[4], 2);
1952+
let mut n = 42;
1953+
swap(&mut n, &mut a[0]);
1954+
assert_eq!(a[0], 42);
1955+
assert_eq!(n, 0);
1956+
}

src/test/ui/swap-2.rs

-14
This file was deleted.

0 commit comments

Comments
 (0)