aboutsummaryrefslogtreecommitdiff
path: root/src/cache
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-03 16:55:58 +0200
committerZeyla Hellyer <[email protected]>2017-10-09 15:47:48 -0700
commit06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a (patch)
treeeee16dc9d1c35e2b17a0a59d55cc85fa82726587 /src/cache
parentUse the de-generification trick. (diff)
downloadserenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.tar.xz
serenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.zip
Revert "Use the de-generification trick."
Makes the compiliation time just a bit worse
Diffstat (limited to 'src/cache')
-rw-r--r--src/cache/mod.rs52
1 files changed, 9 insertions, 43 deletions
diff --git a/src/cache/mod.rs b/src/cache/mod.rs
index def6ac4..2bbc9bc 100644
--- a/src/cache/mod.rs
+++ b/src/cache/mod.rs
@@ -298,10 +298,8 @@ impl Cache {
/// [`groups`]: #structfield.groups
/// [`private_channels`]: #structfield.private_channels
pub fn channel<C: Into<ChannelId>>(&self, id: C) -> Option<Channel> {
- self._channel(id.into())
- }
+ let id = id.into();
- fn _channel(&self, id: ChannelId) -> Option<Channel> {
if let Some(channel) = self.channels.get(&id) {
return Some(Channel::Guild(channel.clone()));
}
@@ -348,11 +346,7 @@ impl Cache {
/// ```
#[inline]
pub fn guild<G: Into<GuildId>>(&self, id: G) -> Option<Arc<RwLock<Guild>>> {
- self._guild(id.into())
- }
-
- fn _guild(&self, id: GuildId) -> Option<Arc<RwLock<Guild>>> {
- self.guilds.get(&id).cloned()
+ self.guilds.get(&id.into()).cloned()
}
/// Retrieves a reference to a [`Guild`]'s channel. Unlike [`channel`],
@@ -401,11 +395,7 @@ impl Cache {
/// [`channel`]: #method.channel
#[inline]
pub fn guild_channel<C: Into<ChannelId>>(&self, id: C) -> Option<Arc<RwLock<GuildChannel>>> {
- self._guild_channel(id.into())
- }
-
- fn _guild_channel(&self, id: ChannelId) -> Option<Arc<RwLock<GuildChannel>>> {
- self.channels.get(&id).cloned()
+ self.channels.get(&id.into()).cloned()
}
/// Retrieves a reference to a [`Group`] from the cache based on the given
@@ -441,11 +431,7 @@ impl Cache {
/// ```
#[inline]
pub fn group<C: Into<ChannelId>>(&self, id: C) -> Option<Arc<RwLock<Group>>> {
- self._group(id.into())
- }
-
- fn _group(&self, id: ChannelId) -> Option<Arc<RwLock<Group>>> {
- self.groups.get(&id).cloned()
+ self.groups.get(&id.into()).cloned()
}
/// Retrieves a [`Guild`]'s member from the cache based on the guild's and
@@ -495,10 +481,6 @@ impl Cache {
/// [`members`]: ../model/struct.Guild.html#structfield.members
pub fn member<G, U>(&self, guild_id: G, user_id: U) -> Option<Member>
where G: Into<GuildId>, U: Into<UserId> {
- self._member(guild_id.into(), user_id.into())
- }
-
- fn _member(&self, guild_id: GuildId, user_id: UserId) -> Option<Member> {
self.guilds.get(&guild_id.into()).and_then(|guild| {
guild.read().unwrap().members.get(&user_id.into()).cloned()
})
@@ -536,11 +518,7 @@ impl Cache {
pub fn private_channel<C: Into<ChannelId>>(&self,
channel_id: C)
-> Option<Arc<RwLock<PrivateChannel>>> {
- self._private_channel(channel_id.into())
- }
-
- fn _private_channel(&self, channel_id: ChannelId) -> Option<Arc<RwLock<PrivateChannel>>> {
- self.private_channels.get(&channel_id).cloned()
+ self.private_channels.get(&channel_id.into()).cloned()
}
/// Retrieves a [`Guild`]'s role by their Ids.
@@ -575,13 +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._role(guild_id.into(), role_id.into())
- }
-
- fn _role(&self, guild_id: GuildId, role_id: RoleId) -> Option<Role> {
self.guilds
- .get(&guild_id)
- .and_then(|g| g.read().unwrap().roles.get(&role_id).cloned())
+ .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.
@@ -616,22 +590,14 @@ impl Cache {
/// ```
#[inline]
pub fn user<U: Into<UserId>>(&self, user_id: U) -> Option<Arc<RwLock<User>>> {
- self._user(user_id.into())
- }
-
- fn _user(&self, user_id: UserId) -> Option<Arc<RwLock<User>>> {
- self.users.get(&user_id).cloned()
+ self.users.get(&user_id.into()).cloned()
}
#[inline]
pub fn categories<C: Into<ChannelId>>(&self,
channel_id: C)
-> Option<Arc<RwLock<ChannelCategory>>> {
- self._categories(channel_id.into())
- }
-
- fn _categories(&self, channel_id: ChannelId) -> Option<Arc<RwLock<ChannelCategory>>> {
- self.categories.get(&channel_id).cloned()
+ self.categories.get(&channel_id.into()).cloned()
}
#[cfg(feature = "client")]