diff options
| author | acdenisSK <[email protected]> | 2017-08-24 15:26:49 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-08-24 16:36:01 +0200 |
| commit | b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3 (patch) | |
| tree | 315e16f7b252d22b5f832302e722a85c9e6a9b6e /src/cache/mod.rs | |
| parent | Allow FromStr for User to use REST (#147) (diff) | |
| download | serenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.tar.xz serenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.zip | |
Revamp `RwLock` usage in the lib
Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
Diffstat (limited to 'src/cache/mod.rs')
| -rw-r--r-- | src/cache/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 68a78a7..4aa587f 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -482,7 +482,7 @@ impl Cache { pub fn member<G, U>(&self, guild_id: G, user_id: U) -> Option<Member> where G: Into<GuildId>, U: Into<UserId> { self.guilds.get(&guild_id.into()).and_then(|guild| { - guild.write().unwrap().members.get(&user_id.into()).cloned() + guild.read().unwrap().members.get(&user_id.into()).cloned() }) } @@ -517,7 +517,7 @@ impl Cache { #[inline] pub fn private_channel<C: Into<ChannelId>>(&self, channel_id: C) - -> Option<Arc<RwLock<PrivateChannel>>> { +-> Option<Arc<RwLock<PrivateChannel>>>{ self.private_channels.get(&channel_id.into()).cloned() } @@ -553,9 +553,9 @@ impl Cache { /// ``` pub fn role<G, R>(&self, guild_id: G, role_id: R) -> Option<Role> where G: Into<GuildId>, R: Into<RoleId> { - self.guilds.get(&guild_id.into()).and_then(|g| { - g.read().unwrap().roles.get(&role_id.into()).cloned() - }) + self.guilds + .get(&guild_id.into()) + .and_then(|g| g.read().unwrap().roles.get(&role_id.into()).cloned()) } /// Retrieves a `User` from the cache's [`users`] map, if it exists. |