Iter<T> acts like a &T so it's Send impl should depend on T: Sync, not T: Send.
unsafe impl<'a, T: Send> Send for Iter<'a, T> {}
should be
unsafe impl<'a, T: Sync> Send for Iter<'a, T> {}
Here's some example code which shouldn't compile but does.
let mut list = LinkedList::new();
list.push_back(Cell::new(0));
let mut iter_a = list.iter();
let mut iter_b = list.iter();
std::thread::scope(move |scope| {
scope.spawn(move || iter_a.next().unwrap().set(1));
scope.spawn(move || iter_b.next().unwrap().set(2));
});
Iter<T>acts like a&Tso it'sSendimpl should depend onT: Sync, notT: Send.should be
Here's some example code which shouldn't compile but does.