aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/message_builder.rs18
-rw-r--r--src/utils/mod.rs5
2 files changed, 18 insertions, 5 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
}
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 544aef4..e20dd22 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -348,9 +348,12 @@ pub fn parse_emoji(mention: &str) -> Option<EmojiIdentifier> {
/// ```
///
/// [`EditProfile::avatar`]: ../builder/struct.EditProfile.html#method.avatar
+#[inline]
pub fn read_image<P: AsRef<Path>>(path: P) -> Result<String> {
- let path = path.as_ref();
+ _read_image(path.as_ref())
+}
+fn _read_image(path: &Path) -> Result<String> {
let mut v = Vec::default();
let mut f = File::open(path)?;
let _ = f.read_to_end(&mut v);