From 6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Mon, 2 Oct 2017 22:29:10 +0200 Subject: Use the de-generification trick. Fixes #168 --- src/utils/message_builder.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/utils') diff --git a/src/utils/message_builder.rs b/src/utils/message_builder.rs index f58c0b3..e1ba328 100644 --- a/src/utils/message_builder.rs +++ b/src/utils/message_builder.rs @@ -122,8 +122,12 @@ impl MessageBuilder { /// [`ChannelId`]: ../model/struct.ChannelId.html /// [`GuildChannel`]: ../model/struct.GuildChannel.html /// [Display implementation]: ../model/struct.ChannelId.html#method.fmt-1 - pub fn channel>(mut self, channel: C) -> Self { - let _ = write!(self.0, "{}", channel.into().mention()); + pub fn channel>(self, channel: C) -> Self { + self._channel(channel.into()) + } + + fn _channel(mut self, channel: ChannelId) -> Self { + let _ = write!(self.0, "{}", channel.mention()); self } @@ -701,8 +705,12 @@ impl MessageBuilder { /// [`Role`]: ../model/struct.Role.html /// [`RoleId`]: ../model/struct.RoleId.html /// [Display implementation]: ../model/struct.RoleId.html#method.fmt-1 - pub fn role>(mut self, role: R) -> Self { - let _ = write!(self.0, "{}", role.into().mention()); + pub fn role>(self, role: R) -> Self { + self._role(role.into()) + } + + fn _role(mut self, role: RoleId) -> Self { + let _ = write!(self.0, "{}", role.mention()); self } @@ -718,8 +726,12 @@ impl MessageBuilder { /// [`User`]: ../model/struct.User.html /// [`UserId`]: ../model/struct.UserId.html /// [Display implementation]: ../model/struct.UserId.html#method.fmt-1 - pub fn user>(mut self, user: U) -> Self { - let _ = write!(self.0, "{}", user.into().mention()); + pub fn user>(self, user: U) -> Self { + self._user(user.into()) + } + + fn _user(mut self, user: UserId) -> Self { + let _ = write!(self.0, "{}", user.mention()); self } -- cgit v1.2.3