The following code fixes the issue, however when one wants to make it nice maybe use pointers like the comments suggest.
use crossbeam::thread;
use std::cell::Cell;
use std::sync::Arc;
pub struct ThreadCell<T>(pub Cell<T>);
unsafe impl<T> Send for ThreadCell<T> {}
unsafe impl<T> Sync for ThreadCell<T> {}
struct Ship {
hull: ThreadCell<f32>,
info: Arc<ShipInfo>,
}
fn shoot(slicea: &[Ship],sliceb: &[Ship]){
// Shooting logic here
}
fn multishoot(slicea: &[Ship],sliceb: &[Ship]){
thread::scope(|s| {
s.spawn(|_| {
shoot(slicea, sliceb);
});
s.spawn(|_| {
shoot(sliceb, slicea);
});
})
.unwrap();
}