aboutsummaryrefslogtreecommitdiff
path: root/src/builder/create_message.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/builder/create_message.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/builder/create_message.rs')
-rw-r--r--src/builder/create_message.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs
index df6f4d5..a5ede5a 100644
--- a/src/builder/create_message.rs
+++ b/src/builder/create_message.rs
@@ -46,8 +46,13 @@ impl CreateMessage {
/// Set the content of the message.
///
/// **Note**: Message contents must be under 2000 unicode code points.
- pub fn content<D: Display>(mut self, content: D) -> Self {
- self.0.insert("content", Value::String(content.to_string()));
+ #[inline]
+ pub fn content<D: Display>(self, content: D) -> Self {
+ self._content(content.to_string())
+ }
+
+ fn _content(mut self, content: String) -> Self {
+ self.0.insert("content", Value::String(content));
self
}
@@ -75,8 +80,13 @@ impl CreateMessage {
}
/// Adds a list of reactions to create after the message's sent.
- pub fn reactions<R: Into<ReactionType>, It: IntoIterator<Item=R>>(mut self, reactions: It) -> Self {
- self.1 = Some(reactions.into_iter().map(|r| r.into()).collect());
+ #[inline]
+ pub fn reactions<R: Into<ReactionType>, It: IntoIterator<Item=R>>(self, reactions: It) -> Self {
+ self._reactions(reactions.into_iter().map(Into::into).collect())
+ }
+
+ fn _reactions(mut self, reactions: Vec<ReactionType>) -> Self {
+ self.1 = Some(reactions);
self
}