From 39b1f1fa72537724c95cd208d6ce0034a5be6e9f Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 21 Jan 2024 17:07:19 +0100 Subject: [PATCH] Replace use of Arc> with Shared --- src/gateway/handle.rs | 6 +++--- tests/common/mod.rs | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gateway/handle.rs b/src/gateway/handle.rs index 620faba..d44dfa2 100644 --- a/src/gateway/handle.rs +++ b/src/gateway/handle.rs @@ -42,8 +42,8 @@ impl GatewayHandle { pub async fn observe>( &self, - object: Arc>, - ) -> Arc> { + object: Shared, + ) -> Shared { let mut store = self.store.lock().await; let id = object.read().unwrap().id(); if let Some(channel) = store.get(&id) { @@ -84,7 +84,7 @@ impl GatewayHandle { /// with all of its observable fields being observed. pub async fn observe_and_into_inner>( &self, - object: Arc>, + object: Shared, ) -> T { let channel = self.observe(object.clone()).await; let object = channel.read().unwrap().clone(); diff --git a/tests/common/mod.rs b/tests/common/mod.rs index bce419a..eae2b26 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,6 +1,5 @@ -use std::sync::{Arc, RwLock}; - -use chorus::gateway::Gateway; +use chorus::gateway::{Gateway, Shared}; +use chorus::types::Composite; use chorus::{ instance::{ChorusUser, Instance}, types::{ @@ -16,9 +15,9 @@ pub(crate) struct TestBundle { pub urls: UrlBundle, pub user: ChorusUser, pub instance: Instance, - pub guild: Arc>, - pub role: Arc>, - pub channel: Arc>, + pub guild: Shared, + pub role: Shared, + pub channel: Shared, } #[allow(unused)] @@ -119,9 +118,9 @@ pub(crate) async fn setup() -> TestBundle { urls, user, instance, - guild: Arc::new(RwLock::new(guild)), - role: Arc::new(RwLock::new(role)), - channel: Arc::new(RwLock::new(channel)), + guild: guild.to_shared(), + role: role.to_shared(), + channel: channel.to_shared(), } }