aboutsummaryrefslogtreecommitdiff
path: root/src/builder
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-10-03 16:55:58 +0200
committerZeyla Hellyer <[email protected]>2017-10-09 15:47:48 -0700
commit06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a (patch)
treeeee16dc9d1c35e2b17a0a59d55cc85fa82726587 /src/builder
parentUse the de-generification trick. (diff)
downloadserenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.tar.xz
serenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.zip
Revert "Use the de-generification trick."
Makes the compiliation time just a bit worse
Diffstat (limited to 'src/builder')
-rw-r--r--src/builder/create_embed.rs16
-rw-r--r--src/builder/create_message.rs6
-rw-r--r--src/builder/edit_guild.rs27
-rw-r--r--src/builder/edit_member.rs8
-rw-r--r--src/builder/get_messages.rs24
5 files changed, 21 insertions, 60 deletions
diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs
index 7303693..a128c91 100644
--- a/src/builder/create_embed.rs
+++ b/src/builder/create_embed.rs
@@ -62,20 +62,14 @@ impl CreateEmbed {
/// [`colour`]: #method.colour
#[cfg(feature = "utils")]
#[inline]
- pub fn color<C: Into<Colour>>(self, colour: C) -> Self { self.colour(colour) }
+ pub fn color<C: Into<Colour>>(self, colour: C) -> Self { self.colour(colour.into()) }
-
/// Set the colour of the left-hand side of the embed.
#[cfg(feature = "utils")]
pub fn colour<C: Into<Colour>>(mut self, colour: C) -> Self {
- self._colour(colour.into())
- }
-
- #[cfg(feature = "utils")]
- fn _colour(mut self, colour: Colour) -> Self {
self.0.insert(
"color".to_string(),
- Value::Number(Number::from(colour.0 as u64)),
+ Value::Number(Number::from(colour.into().0 as u64)),
);
CreateEmbed(self.0)
@@ -288,12 +282,8 @@ impl CreateEmbed {
/// let mut client = Client::new("token", Handler); client.start().unwrap();
/// ```
pub fn timestamp<T: Into<Timestamp>>(mut self, timestamp: T) -> Self {
- self._timestamp(timestamp.into())
- }
-
- fn _timestamp(mut self, timestamp: Timestamp) -> Self {
self.0
- .insert("timestamp".to_string(), Value::String(timestamp.ts));
+ .insert("timestamp".to_string(), Value::String(timestamp.into().ts));
CreateEmbed(self.0)
}
diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs
index 123c0b5..96bad82 100644
--- a/src/builder/create_message.rs
+++ b/src/builder/create_message.rs
@@ -75,11 +75,7 @@ impl CreateMessage {
/// Adds a list of reactions to create after the message's sent.
pub fn reactions<R: Into<ReactionType>>(mut self, reactions: Vec<R>) -> Self {
- self._reactions(reactions.into_iter().map(|r| r.into()).collect())
- }
-
- fn _reactions(mut self, reactions: Vec<ReactionType>) -> Self {
- self.1 = Some(reactions);
+ self.1 = Some(reactions.into_iter().map(|r| r.into()).collect());
CreateMessage(self.0, self.1)
}
diff --git a/src/builder/edit_guild.rs b/src/builder/edit_guild.rs
index a4f2c54..0719305 100644
--- a/src/builder/edit_guild.rs
+++ b/src/builder/edit_guild.rs
@@ -22,14 +22,13 @@ impl EditGuild {
/// valid.
///
/// [`afk_timeout`]: #method.afk_timeout
- pub fn afk_channel<C: Into<ChannelId>>(self, channel: Option<C>) -> Self {
- self._afk_channel(channel.map(|c| c.into()))
- }
-
- fn _afk_channel(mut self, channel: Option<ChannelId>) -> Self {
+ pub fn afk_channel<C: Into<ChannelId>>(mut self, channel: Option<C>) -> Self {
self.0.insert(
"afk_channel_id".to_string(),
- channel.map_or(Value::Null, |ChannelId(id)| Value::Number(Number::from(id)))
+ match channel {
+ Some(channel) => Value::Number(Number::from(channel.into().0)),
+ None => Value::Null,
+ },
);
self
@@ -99,14 +98,10 @@ 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>>(self, user_id: U) -> Self {
- self._owner(user_id.into())
- }
-
- fn _owner(mut self, user_id: UserId) -> Self {
+ pub fn owner<U: Into<UserId>>(mut self, user_id: U) -> Self {
self.0.insert(
"owner_id".to_string(),
- Value::Number(Number::from(user_id.0)),
+ Value::Number(Number::from(user_id.into().0)),
);
self
@@ -190,13 +185,9 @@ impl EditGuild {
///
/// [`VerificationLevel`]: ../model/enum.VerificationLevel.html
/// [`VerificationLevel::High`]: ../model/enum.VerificationLevel.html#variant.High
- pub fn verification_level<V>(self, verification_level: V) -> Self
+ pub fn verification_level<V>(mut self, verification_level: V) -> Self
where V: Into<VerificationLevel> {
- self._verification_level(verification_level.into())
- }
-
- fn _verification_level(mut self, verification_level: VerificationLevel) -> Self {
- let num = Value::Number(Number::from(verification_level.num()));
+ let num = Value::Number(Number::from(verification_level.into().num()));
self.0.insert("verification_level".to_string(), num);
diff --git a/src/builder/edit_member.rs b/src/builder/edit_member.rs
index 53cf0d0..e450669 100644
--- a/src/builder/edit_member.rs
+++ b/src/builder/edit_member.rs
@@ -66,14 +66,10 @@ impl EditMember {
/// Requires the [Move Members] permission.
///
/// [Move Members]: ../model/permissions/constant.MOVE_MEMBERS.html
- pub fn voice_channel<C: Into<ChannelId>>(self, channel_id: C) -> Self {
- self._voice_channel(channel_id.into())
- }
-
- fn _voice_channel(mut self, channel_id: ChannelId) -> Self {
+ pub fn voice_channel<C: Into<ChannelId>>(mut self, channel_id: C) -> Self {
self.0.insert(
"channel_id".to_string(),
- Value::Number(Number::from(channel_id.0)),
+ Value::Number(Number::from(channel_id.into().0)),
);
self
diff --git a/src/builder/get_messages.rs b/src/builder/get_messages.rs
index eff90f4..71af9e5 100644
--- a/src/builder/get_messages.rs
+++ b/src/builder/get_messages.rs
@@ -55,36 +55,24 @@ pub struct GetMessages(pub BTreeMap<String, u64>);
impl GetMessages {
/// Indicates to retrieve the messages after a specific message, given by
/// its Id.
- pub fn after<M: Into<MessageId>>(self, message_id: M) -> Self {
- self._after(message_id.into())
- }
-
- fn _after(mut self, MessageId(id): MessageId) -> Self {
- self.0.insert("after".to_string(), id);
+ pub fn after<M: Into<MessageId>>(mut self, message_id: M) -> Self {
+ self.0.insert("after".to_string(), message_id.into().0);
self
}
/// Indicates to retrieve the messages _around_ a specific message in either
/// direction (before+after) the given message.
- pub fn around<M: Into<MessageId>>(self, message_id: M) -> Self {
- self._around(message_id.into())
- }
-
- fn _around(mut self, MessageId(id): MessageId) -> Self {
- self.0.insert("around".to_string(), id);
+ pub fn around<M: Into<MessageId>>(mut self, message_id: M) -> Self {
+ self.0.insert("around".to_string(), message_id.into().0);
self
}
/// Indicates to retrieve the messages before a specific message, given by
/// its Id.
- pub fn before<M: Into<MessageId>>(self, message_id: M) -> Self {
- self._before(message_id.into())
- }
-
- fn _before(mut self, MessageId(id): MessageId) -> Self {
- self.0.insert("before".to_string(), id);
+ pub fn before<M: Into<MessageId>>(mut self, message_id: M) -> Self {
+ self.0.insert("before".to_string(), message_id.into().0);
self
}