#![allow(unused_variables)] fn main() { use std::sync::Arc; #[derive(Clone)] struct LinkedList(Option>>); struct Node(T, Option>>); impl Drop for LinkedList { fn drop(&mut self) { let mut link = self.0.take(); while let Some(arc_node) = link.take() { if let Some(Node(_value, next)) = Arc::into_inner(arc_node) { link = next; } } } } impl LinkedList { fn new() -> Self { LinkedList(None) } fn push(&mut self, x: T) { self.0 = Some(Arc::new(Node(x, self.0.take()))); } } let mut x = LinkedList::new(); let size = 100000; let size = if cfg!(miri) { 100 } else { size }; for i in 0..size { x.push(i); } let y = x.clone(); let x_thread = std::thread::spawn(|| drop(x)); let y_thread = std::thread::spawn(|| drop(y)); x_thread.join().unwrap(); y_thread.join().unwrap(); }