letmut a = (0..test_vec_len).collect::<Vec<_>>(); let b = (0..test_vec_len).collect::<Vec<_>>();
let _result = panic::catch_unwind(panic::AssertUnwindSafe(|| { letmut result = Vec::new();
a.par_iter_mut()
.zip(&b)
.map(|(&mut a, &b)| { if a > panic_point && will_panic {
panic!("unwinding for test");
} let elt = a + b;
inserts.lock().unwrap().push(elt);
Recorddrop(elt, &drops)
})
.collect_into_vec(&mut result);
// If we reach this point, this must pass
assert_eq!(a.len(), result.len());
}));
let inserts = inserts.get_mut().unwrap(); let drops = drops.get_mut().unwrap();
println!("{:?}", inserts);
println!("{:?}", drops);
assert_eq!(inserts.len(), drops.len(), "Incorrect number of drops"); // sort to normalize order
inserts.sort();
drops.sort();
assert_eq!(inserts, drops, "Incorrect elements were dropped");
};
for &should_panic in &[true, false] {
test_collect_panic(should_panic);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.