diff options
| author | acdenisSK <[email protected]> | 2017-10-03 16:55:58 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-10-03 16:55:58 +0200 |
| commit | 2233337d334e52b5c4cf7149097e70ef5c5433b3 (patch) | |
| tree | ba14ca714fa7bc1e6ba1d26f10e7c170bdf10ffa /src/model/guild/mod.rs | |
| parent | Use the de-generification trick. (diff) | |
| download | serenity-2233337d334e52b5c4cf7149097e70ef5c5433b3.tar.xz serenity-2233337d334e52b5c4cf7149097e70ef5c5433b3.zip | |
Revert "Use the de-generification trick."
Makes the compiliation time just a bit worse
Diffstat (limited to 'src/model/guild/mod.rs')
| -rw-r--r-- | src/model/guild/mod.rs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index a3fa055..8173a04 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -205,10 +205,6 @@ impl Guild { /// [`User`]: struct.User.html /// [Ban Members]: permissions/constant.BAN_MEMBERS.html pub fn ban<U: Into<UserId>, BO: BanOptions>(&self, user: U, options: BO) -> Result<()> { - self._ban(user.into(), options) - } - - fn _ban<BO: BanOptions>(&self, user: UserId, options: BO) -> Result<()> { #[cfg(feature = "cache")] { let req = Permissions::BAN_MEMBERS; @@ -604,9 +600,7 @@ impl Guild { /// /// Requires that the current user be in the guild. #[inline] - pub fn get<G: Into<GuildId>>(guild_id: G) -> Result<PartialGuild> { Self::_get(guild_id.into()) } - - fn _get(guild_id: GuildId) -> Result<PartialGuild> { guild_id.get() } + pub fn get<G: Into<GuildId>>(guild_id: G) -> Result<PartialGuild> { guild_id.into().get() } /// Returns the formatted URL of the guild's icon, if one exists. pub fn icon_url(&self) -> Option<String> { @@ -763,15 +757,15 @@ impl Guild { /// [`User`]: struct.User.html pub fn permissions_for<C, U>(&self, channel_id: C, user_id: U) -> Permissions where C: Into<ChannelId>, U: Into<UserId> { - self._permissions_for(channel_id.into(), user_id.into()) - } + let user_id = user_id.into(); - fn _permissions_for(&self, ChannelId(cid): ChannelId, UserId(uid): UserId) -> Permissions { // The owner has all permissions in all cases. - if self.owner_id == uid { + if user_id == self.owner_id { return Permissions::all(); } + let channel_id = channel_id.into(); + // Start by retrieving the @everyone role's permissions. let everyone = match self.roles.get(&RoleId(self.id.0)) { Some(everyone) => everyone, @@ -789,7 +783,7 @@ impl Guild { // Create a base set of permissions, starting with `@everyone`s. let mut permissions = everyone.permissions; - let member = match self.members.get(&UserId(uid)) { + let member = match self.members.get(&user_id) { Some(member) => member, None => return everyone.permissions, }; @@ -812,7 +806,7 @@ impl Guild { return Permissions::all(); } - if let Some(channel) = self.channels.get(&ChannelId(cid)) { + if let Some(channel) = self.channels.get(&channel_id) { let channel = channel.read().unwrap(); // If this is a text channel, then throw out voice permissions. @@ -845,7 +839,7 @@ impl Guild { // Member for overwrite in &channel.permission_overwrites { - if PermissionOverwriteType::Member(UserId(uid)) != overwrite.kind { + if PermissionOverwriteType::Member(user_id) != overwrite.kind { continue; } @@ -855,12 +849,12 @@ impl Guild { warn!( "(╯°□°)╯︵ ┻━┻ Guild {} does not contain channel {}", self.id, - cid + channel_id ); } // The default channel is always readable. - if cid == self.id.0 { + if channel_id.0 == self.id.0 { permissions |= Permissions::READ_MESSAGES; } @@ -1013,10 +1007,6 @@ impl Guild { /// [`User`]: struct.User.html /// [Ban Members]: permissions/constant.BAN_MEMBERS.html pub fn unban<U: Into<UserId>>(&self, user_id: U) -> Result<()> { - self._unban(user_id.into()) - } - - fn _unban(&self, user_id: UserId) -> Result<()> { #[cfg(feature = "cache")] { let req = Permissions::BAN_MEMBERS; |