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_guild.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_guild.rs')
| -rw-r--r-- | src/builder/edit_guild.rs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/builder/edit_guild.rs b/src/builder/edit_guild.rs index c24b9b4..28abda7 100644 --- a/src/builder/edit_guild.rs +++ b/src/builder/edit_guild.rs @@ -23,11 +23,16 @@ impl EditGuild { /// valid. /// /// [`afk_timeout`]: #method.afk_timeout - pub fn afk_channel<C: Into<ChannelId>>(mut self, channel: Option<C>) -> Self { + #[inline] + pub fn afk_channel<C: Into<ChannelId>>(self, channel: Option<C>) -> Self { + self._afk_channel(channel.map(Into::into)) + } + + fn _afk_channel(mut self, channel: Option<ChannelId>) -> Self { self.0.insert( "afk_channel_id", match channel { - Some(channel) => Value::Number(Number::from(channel.into().0)), + Some(channel) => Value::Number(Number::from(channel.0)), None => Value::Null, }, ); @@ -98,8 +103,13 @@ impl EditGuild { /// Transfers the ownership of the guild to another user by Id. /// /// **Note**: The current user must be the owner of the guild. - pub fn owner<U: Into<UserId>>(mut self, user_id: U) -> Self { - let id = Value::Number(Number::from(user_id.into().0)); + #[inline] + pub fn owner<U: Into<UserId>>(self, user_id: U) -> Self { + self._owner(user_id.into()) + } + + fn _owner(mut self, user_id: UserId) -> Self { + let id = Value::Number(Number::from(user_id.0)); self.0.insert("owner_id", id); self @@ -180,10 +190,14 @@ impl EditGuild { /// /// [`VerificationLevel`]: ../model/guild/enum.VerificationLevel.html /// [`VerificationLevel::High`]: ../model/guild/enum.VerificationLevel.html#variant.High - pub fn verification_level<V>(mut self, verification_level: V) -> Self + #[inline] + pub fn verification_level<V>(self, verification_level: V) -> Self where V: Into<VerificationLevel> { - let num = Value::Number(Number::from(verification_level.into().num())); + self._verification_level(verification_level.into()) + } + fn _verification_level(mut self, verification_level: VerificationLevel) -> Self { + let num = Value::Number(Number::from(verification_level.num())); self.0.insert("verification_level", num); self |