aboutsummaryrefslogtreecommitdiff
path: root/src/model/user.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-07-04 21:28:22 -0700
committerZeyla Hellyer <[email protected]>2018-07-04 21:32:17 -0700
commit7b9764cf1097b0620d871fabe67b5593f0cd4a4a (patch)
tree5b9f3eac6e9c57ac255c73bd1eea07669838f32d /src/model/user.rs
parentFix dead doc-links and add missing ones. (#347) (diff)
downloadserenity-7b9764cf1097b0620d871fabe67b5593f0cd4a4a.tar.xz
serenity-7b9764cf1097b0620d871fabe67b5593f0cd4a4a.zip
Monomorphize all functions
This commit monomorphizes all functions, turning functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { baz = baz.into(); // function here } ``` Into functions like: ```rust fn foo<T: Into<Bar>>(baz: T) { _foo(baz.into()) } fn _foo(baz: Bar) { // function here } ``` This avoids binary bloat and improves build times, by reducing the amount of code duplication.
Diffstat (limited to 'src/model/user.rs')
-rw-r--r--src/model/user.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index 330f319..48891d3 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -580,10 +580,12 @@ 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())
+ }
+ fn _has_role(&self, guild: GuildContainer, role: RoleId) -> bool {
match guild.into() {
- GuildContainer::Guild(guild) => guild.roles.contains_key(&role_id),
+ GuildContainer::Guild(guild) => guild.roles.contains_key(&role),
GuildContainer::Id(_guild_id) => {
feature_cache! {{
CACHE.read()
@@ -591,7 +593,7 @@ impl User {
.get(&_guild_id)
.map(|g| {
g.read().members.get(&self.id)
- .map(|m| m.roles.contains(&role_id))
+ .map(|m| m.roles.contains(&role))
.unwrap_or(false)
})
.unwrap_or(false)