From 06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Tue, 3 Oct 2017 16:55:58 +0200 Subject: Revert "Use the de-generification trick." Makes the compiliation time just a bit worse --- src/cache/mod.rs | 52 +++++++++------------------------------------------- 1 file changed, 9 insertions(+), 43 deletions(-) (limited to 'src/cache') 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>(&self, id: C) -> Option { - self._channel(id.into()) - } + let id = id.into(); - fn _channel(&self, id: ChannelId) -> Option { if let Some(channel) = self.channels.get(&id) { return Some(Channel::Guild(channel.clone())); } @@ -348,11 +346,7 @@ impl Cache { /// ``` #[inline] pub fn guild>(&self, id: G) -> Option>> { - self._guild(id.into()) - } - - fn _guild(&self, id: GuildId) -> Option>> { - 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>(&self, id: C) -> Option>> { - self._guild_channel(id.into()) - } - - fn _guild_channel(&self, id: ChannelId) -> Option>> { - 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>(&self, id: C) -> Option>> { - self._group(id.into()) - } - - fn _group(&self, id: ChannelId) -> Option>> { - 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(&self, guild_id: G, user_id: U) -> Option where G: Into, U: Into { - self._member(guild_id.into(), user_id.into()) - } - - fn _member(&self, guild_id: GuildId, user_id: UserId) -> Option { 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>(&self, channel_id: C) -> Option>> { - self._private_channel(channel_id.into()) - } - - fn _private_channel(&self, channel_id: ChannelId) -> Option>> { - 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(&self, guild_id: G, role_id: R) -> Option where G: Into, R: Into { - self._role(guild_id.into(), role_id.into()) - } - - fn _role(&self, guild_id: GuildId, role_id: RoleId) -> Option { 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>(&self, user_id: U) -> Option>> { - self._user(user_id.into()) - } - - fn _user(&self, user_id: UserId) -> Option>> { - self.users.get(&user_id).cloned() + self.users.get(&user_id.into()).cloned() } #[inline] pub fn categories>(&self, channel_id: C) -> Option>> { - self._categories(channel_id.into()) - } - - fn _categories(&self, channel_id: ChannelId) -> Option>> { - self.categories.get(&channel_id).cloned() + self.categories.get(&channel_id.into()).cloned() } #[cfg(feature = "client")] -- cgit v1.2.3