use slicefire::*;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[allow(unused)]
struct Foo {
x: i32,
y: i64,
}
impl From<i32> for Foo {
fn from(x: i32) -> Self {
Self { x, y: x as i64 * 2 }
}
}
fn indices(size: usize) -> (Vec<usize>, Vec<Foo>) {
let indices = (0..(size)).map(|i| i % (size - 2)).collect::<Vec<usize>>();
let vs = (0..size).map(|v| (v as i32).into()).collect::<Vec<Foo>>();
(indices, vs)
}
#[test]
fn writes_where_it_should() {
let (indices, mut vs) = indices(10);
writes_par(&mut vs, 10.into(), &indices);
let penultimate = vs.len() - 2;
let val = penultimate as i32;
let last_two = &vs[penultimate..];
assert_eq!(last_two[0], val.into());
assert_eq!(last_two[1], (val + 1).into());
}