use std::sync::Arc; use tokio::sync::Mutex; pub struct SyncVec { x: Arc>>, } impl Default for SyncVec { fn default() -> Self { Self { x: Default::default(), } } } impl Clone for SyncVec { fn clone(&self) -> Self { Self { x: self.x.clone() } } } impl SyncVec { pub async fn push(&self, value: T) { self.x.lock().await.push(value) } } impl SyncVec where T: Clone, { pub async fn clone_vec(&self) -> Vec { self.x.lock().await.clone() } }