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/builder/edit_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/builder/edit_member.rs')
| -rw-r--r-- | src/builder/edit_member.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/builder/edit_member.rs b/src/builder/edit_member.rs index 19edb5e..c0791d6 100644 --- a/src/builder/edit_member.rs +++ b/src/builder/edit_member.rs @@ -50,13 +50,17 @@ impl EditMember { /// Requires the [Manage Roles] permission to modify. /// /// [Manage Roles]: ../model/permissions/constant.MANAGE_ROLES.html - pub fn roles<T: AsRef<RoleId>, It: IntoIterator<Item=T>>(mut self, roles: It) -> Self { - let role_ids = roles + pub fn roles<T: AsRef<RoleId>, It: IntoIterator<Item=T>>(self, roles: It) -> Self { + let roles = roles .into_iter() .map(|x| Value::Number(Number::from(x.as_ref().0))) .collect(); - self.0.insert("roles", Value::Array(role_ids)); + self._roles(roles) + } + + fn _roles(mut self, roles: Vec<Value>) -> Self { + self.0.insert("roles", Value::Array(roles)); self } @@ -66,8 +70,13 @@ impl EditMember { /// Requires the [Move Members] permission. /// /// [Move Members]: ../model/permissions/constant.MOVE_MEMBERS.html - pub fn voice_channel<C: Into<ChannelId>>(mut self, channel_id: C) -> Self { - let num = Value::Number(Number::from(channel_id.into().0)); + #[inline] + pub fn voice_channel<C: Into<ChannelId>>(self, channel_id: C) -> Self { + self._voice_channel(channel_id.into()) + } + + fn _voice_channel(mut self, channel_id: ChannelId) -> Self { + let num = Value::Number(Number::from(channel_id.0)); self.0.insert("channel_id", num); self |