aboutsummaryrefslogtreecommitdiff
path: root/src/model/user.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-02 22:29:10 +0200
committeracdenisSK <[email protected]>2017-10-02 22:29:10 +0200
commit6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249 (patch)
treeae9ad7d7cb73d4ece6a199796af5975545071493 /src/model/user.rs
parent`to_owned` -> `to_string` (diff)
downloadserenity-6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249.tar.xz
serenity-6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249.zip
Use the de-generification trick.
Fixes #168
Diffstat (limited to 'src/model/user.rs')
-rw-r--r--src/model/user.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index 3ae33aa..c3c3c0d 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -573,17 +573,19 @@ impl User {
// no-cache would warn on guild_id.
pub fn has_role<G, R>(&self, guild: G, role: R) -> bool
where G: Into<GuildContainer>, R: Into<RoleId> {
- let role_id = role.into();
+ self._has_role(guild.into(), role.into())
+ }
- match guild.into() {
- GuildContainer::Guild(guild) => guild.roles.contains_key(&role_id),
+ fn _has_role(&self, guild: GuildContainer, role: RoleId) -> bool {
+ match guild {
+ GuildContainer::Guild(guild) => guild.roles.contains_key(&role),
GuildContainer::Id(_guild_id) => {
feature_cache! {{
CACHE.read()
.unwrap()
.guilds
.get(&_guild_id)
- .map(|g| g.read().unwrap().roles.contains_key(&role_id))
+ .map(|g| g.read().unwrap().roles.contains_key(&role))
.unwrap_or(false)
} else {
true