aboutsummaryrefslogtreecommitdiff
path: root/src/utils/message_builder.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/utils/message_builder.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/utils/message_builder.rs')
-rw-r--r--src/utils/message_builder.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/utils/message_builder.rs b/src/utils/message_builder.rs
index 93c5489..15c0b07 100644
--- a/src/utils/message_builder.rs
+++ b/src/utils/message_builder.rs
@@ -129,8 +129,13 @@ impl MessageBuilder {
/// [`ChannelId`]: ../model/id/struct.ChannelId.html
/// [`GuildChannel`]: ../model/channel/struct.GuildChannel.html
/// [Display implementation]: ../model/id/struct.ChannelId.html#method.fmt-1
- pub fn channel<C: Into<ChannelId>>(mut self, channel: C) -> Self {
- let _ = write!(self.0, "{}", channel.into().mention());
+ #[inline]
+ pub fn channel<C: Into<ChannelId>>(self, channel: C) -> Self {
+ self._channel(channel.into())
+ }
+
+ fn _channel(mut self, channel: ChannelId) -> Self {
+ let _ = write!(self.0, "{}", channel.mention());
self
}
@@ -198,8 +203,13 @@ impl MessageBuilder {
///
/// assert_eq!(message.push("ing").0, "testing");
/// ```
- pub fn push<D: I>(mut self, content: D) -> Self {
- self.0.push_str(&content.into().to_string());
+ #[inline]
+ pub fn push<D: I>(self, content: D) -> Self {
+ self._push(content.into().to_string())
+ }
+
+ fn _push(mut self, content: String) -> Self {
+ self.0.push_str(&content);
self
}