clone data and compute expected results before mutating data via quick_sort
@@ -38,11 +38,11 @@ fn sort() {
match result {
Ok(_) => {
- quick_sort(&mut data);
-
let mut sorted_data = data.clone();
sorted_data.sort();
+ quick_sort(&mut data);
+
assert_eq!(data, sorted_data);
}
Err(e) => panic!("expected InitOk, but got {:?}", e),
@@ -58,13 +58,13 @@ fn sort_in_pool() {
match result {
Ok(pool) => {
+ let mut sorted_data = data.clone();
+ sorted_data.sort();
+
pool.install(|| {
quick_sort(&mut data);
});
- let mut sorted_data = data.clone();
- sorted_data.sort();
-
assert_eq!(data, sorted_data);
}
Err(_) => panic!("expected Ok() but got Err()"),
