diff options
| author | Zeyla Hellyer <[email protected]> | 2018-07-04 21:28:22 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-07-04 21:32:17 -0700 |
| commit | 7b9764cf1097b0620d871fabe67b5593f0cd4a4a (patch) | |
| tree | 5b9f3eac6e9c57ac255c73bd1eea07669838f32d /src/model/guild/member.rs | |
| parent | Fix dead doc-links and add missing ones. (#347) (diff) | |
| download | serenity-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/guild/member.rs')
| -rw-r--r-- | src/model/guild/member.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index c95c07f..8101700 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -85,9 +85,13 @@ impl Member { /// [`Role`]: struct.Role.html /// [Manage Roles]: permissions/constant.MANAGE_ROLES.html #[cfg(feature = "cache")] + #[inline] pub fn add_role<R: Into<RoleId>>(&mut self, role_id: R) -> Result<()> { - let role_id = role_id.into(); + self._add_role(role_id.into()) + } + #[cfg(feature = "cache")] + fn _add_role(&mut self, role_id: RoleId) -> Result<()> { if self.roles.contains(&role_id) { return Ok(()); } @@ -140,14 +144,17 @@ impl Member { /// /// [Ban Members]: permissions/constant.BAN_MEMBERS.html #[cfg(feature = "cache")] + #[inline] pub fn ban<BO: BanOptions>(&self, ban_options: &BO) -> Result<()> { - let dmd = ban_options.dmd(); + self._ban(ban_options.dmd(), ban_options.reason()) + } + + #[cfg(feature = "cache")] + fn _ban(&self, dmd: u8, reason: &str) -> Result<()> { if dmd > 7 { return Err(Error::Model(ModelError::DeleteMessageDaysAmount(dmd))); } - let reason = ban_options.reason(); - if reason.len() > 512 { return Err(Error::ExceededLimit(reason.to_string(), 512)); } @@ -368,9 +375,13 @@ impl Member { /// [`Role`]: struct.Role.html /// [Manage Roles]: permissions/constant.MANAGE_ROLES.html #[cfg(feature = "cache")] + #[inline] pub fn remove_role<R: Into<RoleId>>(&mut self, role_id: R) -> Result<()> { - let role_id = role_id.into(); + self._remove_role(role_id.into()) + } + #[cfg(feature = "cache")] + fn _remove_role(&mut self, role_id: RoleId) -> Result<()> { if !self.roles.contains(&role_id) { return Ok(()); } |