1 2 3 4 5 6 7 8 9 10 11 12
use std::sync::Arc; use tokio::sync::{RwLock, RwLockReadGuard}; #[derive(Debug, Clone)] pub struct RLock<T: ?Sized>(pub Arc<RwLock<T>>); impl<T: ?Sized> RLock<T> { pub async fn get(&self) -> RwLockReadGuard<'_, T> { self.0.read().await } }