aboutsummaryrefslogtreecommitdiff
path: root/src/builder
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-09-18 17:48:52 -0700
committerZeyla Hellyer <[email protected]>2017-09-18 17:48:52 -0700
commitdae2cb77b407044f44a7a2790d93efba3891854e (patch)
treebef263c4490536cf8b56e988e71dd1aa43bc2696 /src/builder
parentFix compiles of a variety of feature combinations (diff)
downloadserenity-dae2cb77b407044f44a7a2790d93efba3891854e.tar.xz
serenity-dae2cb77b407044f44a7a2790d93efba3891854e.zip
Apply rustfmt
Diffstat (limited to 'src/builder')
-rw-r--r--src/builder/create_embed.rs71
-rw-r--r--src/builder/create_invite.rs18
-rw-r--r--src/builder/create_message.rs6
-rw-r--r--src/builder/edit_channel.rs24
-rw-r--r--src/builder/edit_guild.rs17
-rw-r--r--src/builder/edit_member.rs6
-rw-r--r--src/builder/edit_profile.rs18
-rw-r--r--src/builder/edit_role.rs61
-rw-r--r--src/builder/execute_webhook.rs12
-rw-r--r--src/builder/get_messages.rs6
10 files changed, 74 insertions, 165 deletions
diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs
index 6d61653..1e0bc8d 100644
--- a/src/builder/create_embed.rs
+++ b/src/builder/create_embed.rs
@@ -87,10 +87,8 @@ impl CreateEmbed {
/// Set the colour of the left-hand side of the embed.
#[cfg(not(feature = "utils"))]
pub fn colour(mut self, colour: u32) -> Self {
- self.0.insert(
- "color".to_owned(),
- Value::Number(Number::from(colour)),
- );
+ self.0
+ .insert("color".to_owned(), Value::Number(Number::from(colour)));
CreateEmbed(self.0)
}
@@ -284,30 +282,24 @@ impl CreateEmbed {
/// let mut client = Client::new("token", Handler); client.start().unwrap();
/// ```
pub fn timestamp<T: Into<Timestamp>>(mut self, timestamp: T) -> Self {
- self.0.insert(
- "timestamp".to_owned(),
- Value::String(timestamp.into().ts),
- );
+ self.0
+ .insert("timestamp".to_owned(), Value::String(timestamp.into().ts));
CreateEmbed(self.0)
}
/// Set the title of the embed.
pub fn title<D: Display>(mut self, title: D) -> Self {
- self.0.insert(
- "title".to_owned(),
- Value::String(format!("{}", title)),
- );
+ self.0
+ .insert("title".to_owned(), Value::String(format!("{}", title)));
CreateEmbed(self.0)
}
/// Set the URL to direct to when clicking on the title.
pub fn url(mut self, url: &str) -> Self {
- self.0.insert(
- "url".to_owned(),
- Value::String(url.to_owned()),
- );
+ self.0
+ .insert("url".to_owned(), Value::String(url.to_owned()));
CreateEmbed(self.0)
}
@@ -327,10 +319,7 @@ impl Default for CreateEmbed {
/// Creates a builder with default values, setting the `type` to `rich`.
fn default() -> CreateEmbed {
let mut map = Map::new();
- map.insert(
- "type".to_owned(),
- Value::String("rich".to_owned()),
- );
+ map.insert("type".to_owned(), Value::String("rich".to_owned()));
CreateEmbed(map)
}
@@ -407,30 +396,24 @@ pub struct CreateEmbedAuthor(pub Map<String, Value>);
impl CreateEmbedAuthor {
/// Set the URL of the author's icon.
pub fn icon_url(mut self, icon_url: &str) -> Self {
- self.0.insert(
- "icon_url".to_owned(),
- Value::String(icon_url.to_owned()),
- );
+ self.0
+ .insert("icon_url".to_owned(), Value::String(icon_url.to_owned()));
self
}
/// Set the author's name.
pub fn name(mut self, name: &str) -> Self {
- self.0.insert(
- "name".to_owned(),
- Value::String(name.to_owned()),
- );
+ self.0
+ .insert("name".to_owned(), Value::String(name.to_owned()));
self
}
/// Set the author's URL.
pub fn url(mut self, url: &str) -> Self {
- self.0.insert(
- "url".to_owned(),
- Value::String(url.to_owned()),
- );
+ self.0
+ .insert("url".to_owned(), Value::String(url.to_owned()));
self
}
@@ -457,20 +440,16 @@ impl CreateEmbedField {
/// Set the field's name. It can't be longer than 256 characters.
pub fn name<D: Display>(mut self, name: D) -> Self {
- self.0.insert(
- "name".to_owned(),
- Value::String(format!("{}", name)),
- );
+ self.0
+ .insert("name".to_owned(), Value::String(format!("{}", name)));
self
}
/// Set the field's value. It can't be longer than 1024 characters.
pub fn value<D: Display>(mut self, value: D) -> Self {
- self.0.insert(
- "value".to_owned(),
- Value::String(format!("{}", value)),
- );
+ self.0
+ .insert("value".to_owned(), Value::String(format!("{}", value)));
self
}
@@ -500,20 +479,16 @@ pub struct CreateEmbedFooter(pub Map<String, Value>);
impl CreateEmbedFooter {
/// Set the icon URL's value. This only supports HTTP(S).
pub fn icon_url(mut self, icon_url: &str) -> Self {
- self.0.insert(
- "icon_url".to_owned(),
- Value::String(icon_url.to_owned()),
- );
+ self.0
+ .insert("icon_url".to_owned(), Value::String(icon_url.to_owned()));
self
}
/// Set the footer's text.
pub fn text<D: Display>(mut self, text: D) -> Self {
- self.0.insert(
- "text".to_owned(),
- Value::String(format!("{}", text)),
- );
+ self.0
+ .insert("text".to_owned(), Value::String(format!("{}", text)));
self
}
diff --git a/src/builder/create_invite.rs b/src/builder/create_invite.rs
index d17f273..58893fc 100644
--- a/src/builder/create_invite.rs
+++ b/src/builder/create_invite.rs
@@ -89,10 +89,8 @@ impl CreateInvite {
/// # }
/// ```
pub fn max_age(mut self, max_age: u64) -> Self {
- self.0.insert(
- "max_age".to_owned(),
- Value::Number(Number::from(max_age)),
- );
+ self.0
+ .insert("max_age".to_owned(), Value::Number(Number::from(max_age)));
self
}
@@ -125,10 +123,8 @@ impl CreateInvite {
/// # }
/// ```
pub fn max_uses(mut self, max_uses: u64) -> Self {
- self.0.insert(
- "max_uses".to_owned(),
- Value::Number(Number::from(max_uses)),
- );
+ self.0
+ .insert("max_uses".to_owned(), Value::Number(Number::from(max_uses)));
self
}
@@ -159,10 +155,8 @@ impl CreateInvite {
/// # }
/// ```
pub fn temporary(mut self, temporary: bool) -> Self {
- self.0.insert(
- "temporary".to_owned(),
- Value::Bool(temporary),
- );
+ self.0
+ .insert("temporary".to_owned(), Value::Bool(temporary));
self
}
diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs
index 1ac5211..dea77e1 100644
--- a/src/builder/create_message.rs
+++ b/src/builder/create_message.rs
@@ -46,10 +46,8 @@ impl CreateMessage {
///
/// **Note**: Message contents must be under 2000 unicode code points.
pub fn content<D: Display>(mut self, content: D) -> Self {
- self.0.insert(
- "content".to_owned(),
- Value::String(format!("{}", content)),
- );
+ self.0
+ .insert("content".to_owned(), Value::String(format!("{}", content)));
CreateMessage(self.0, self.1)
}
diff --git a/src/builder/edit_channel.rs b/src/builder/edit_channel.rs
index a5d799f..e3bf78e 100644
--- a/src/builder/edit_channel.rs
+++ b/src/builder/edit_channel.rs
@@ -27,10 +27,8 @@ impl EditChannel {
///
/// [voice]: ../model/enum.ChannelType.html#variant.Voice
pub fn bitrate(mut self, bitrate: u64) -> Self {
- self.0.insert(
- "bitrate".to_owned(),
- Value::Number(Number::from(bitrate)),
- );
+ self.0
+ .insert("bitrate".to_owned(), Value::Number(Number::from(bitrate)));
self
}
@@ -39,20 +37,16 @@ impl EditChannel {
///
/// Must be between 2 and 100 characters long.
pub fn name(mut self, name: &str) -> Self {
- self.0.insert(
- "name".to_owned(),
- Value::String(name.to_owned()),
- );
+ self.0
+ .insert("name".to_owned(), Value::String(name.to_owned()));
self
}
/// The position of the channel in the channel list.
pub fn position(mut self, position: u64) -> Self {
- self.0.insert(
- "position".to_owned(),
- Value::Number(Number::from(position)),
- );
+ self.0
+ .insert("position".to_owned(), Value::Number(Number::from(position)));
self
}
@@ -65,10 +59,8 @@ impl EditChannel {
///
/// [text]: ../model/enum.ChannelType.html#variant.Text
pub fn topic(mut self, topic: &str) -> Self {
- self.0.insert(
- "topic".to_owned(),
- Value::String(topic.to_owned()),
- );
+ self.0
+ .insert("topic".to_owned(), Value::String(topic.to_owned()));
self
}
diff --git a/src/builder/edit_guild.rs b/src/builder/edit_guild.rs
index 6cfd13a..f88db2a 100644
--- a/src/builder/edit_guild.rs
+++ b/src/builder/edit_guild.rs
@@ -79,10 +79,7 @@ impl EditGuild {
pub fn icon(mut self, icon: Option<&str>) -> Self {
self.0.insert(
"icon".to_owned(),
- icon.map_or_else(
- || Value::Null,
- |x| Value::String(x.to_owned()),
- ),
+ icon.map_or_else(|| Value::Null, |x| Value::String(x.to_owned())),
);
self
@@ -92,10 +89,8 @@ impl EditGuild {
///
/// **Note**: Must be between (and including) 2-100 chracters.
pub fn name(mut self, name: &str) -> Self {
- self.0.insert(
- "name".to_owned(),
- Value::String(name.to_owned()),
- );
+ self.0
+ .insert("name".to_owned(), Value::String(name.to_owned()));
self
}
@@ -139,10 +134,8 @@ impl EditGuild {
///
/// [`Region::UsWest`]: ../model/enum.Region.html#variant.UsWest
pub fn region(mut self, region: Region) -> Self {
- self.0.insert(
- "region".to_owned(),
- Value::String(region.name().to_owned()),
- );
+ self.0
+ .insert("region".to_owned(), Value::String(region.name().to_owned()));
self
}
diff --git a/src/builder/edit_member.rs b/src/builder/edit_member.rs
index 80ec983..23bf1f2 100644
--- a/src/builder/edit_member.rs
+++ b/src/builder/edit_member.rs
@@ -39,10 +39,8 @@ impl EditMember {
///
/// [Manage Nicknames]: ../model/permissions/constant.MANAGE_NICKNAMES.html
pub fn nickname(mut self, nickname: &str) -> Self {
- self.0.insert(
- "nick".to_owned(),
- Value::String(nickname.to_owned()),
- );
+ self.0
+ .insert("nick".to_owned(), Value::String(nickname.to_owned()));
self
}
diff --git a/src/builder/edit_profile.rs b/src/builder/edit_profile.rs
index 3bc121c..6aa4e78 100644
--- a/src/builder/edit_profile.rs
+++ b/src/builder/edit_profile.rs
@@ -61,10 +61,8 @@ impl EditProfile {
///
/// [provided]: #method.password
pub fn email(mut self, email: &str) -> Self {
- self.0.insert(
- "email".to_owned(),
- Value::String(email.to_owned()),
- );
+ self.0
+ .insert("email".to_owned(), Value::String(email.to_owned()));
self
}
@@ -90,10 +88,8 @@ impl EditProfile {
/// [modifying the password]: #method.new_password
/// [modifying the associated email address]: #method.email
pub fn password(mut self, password: &str) -> Self {
- self.0.insert(
- "password".to_owned(),
- Value::String(password.to_owned()),
- );
+ self.0
+ .insert("password".to_owned(), Value::String(password.to_owned()));
self
}
@@ -105,10 +101,8 @@ impl EditProfile {
/// If there are no available discriminators with the requested username,
/// an error will occur.
pub fn username(mut self, username: &str) -> Self {
- self.0.insert(
- "username".to_owned(),
- Value::String(username.to_owned()),
- );
+ self.0
+ .insert("username".to_owned(), Value::String(username.to_owned()));
self
}
diff --git a/src/builder/edit_role.rs b/src/builder/edit_role.rs
index d034149..8be3404 100644
--- a/src/builder/edit_role.rs
+++ b/src/builder/edit_role.rs
@@ -1,6 +1,6 @@
use std::default::Default;
use internal::prelude::*;
-use model::{Permissions, Role, permissions};
+use model::{permissions, Permissions, Role};
/// A builer to create or edit a [`Role`] for use via a number of model methods.
///
@@ -58,22 +58,13 @@ impl EditRole {
#[cfg(not(feature = "utils"))]
{
- map.insert(
- "color".to_owned(),
- Value::Number(Number::from(role.colour)),
- );
+ map.insert("color".to_owned(), Value::Number(Number::from(role.colour)));
}
map.insert("hoist".to_owned(), Value::Bool(role.hoist));
map.insert("managed".to_owned(), Value::Bool(role.managed));
- map.insert(
- "mentionable".to_owned(),
- Value::Bool(role.mentionable),
- );
- map.insert(
- "name".to_owned(),
- Value::String(role.name.clone()),
- );
+ map.insert("mentionable".to_owned(), Value::Bool(role.mentionable));
+ map.insert("name".to_owned(), Value::String(role.name.clone()));
map.insert(
"permissions".to_owned(),
Value::Number(Number::from(role.permissions.bits())),
@@ -88,10 +79,8 @@ impl EditRole {
/// Sets the colour of the role.
pub fn colour(mut self, colour: u64) -> Self {
- self.0.insert(
- "color".to_owned(),
- Value::Number(Number::from(colour)),
- );
+ self.0
+ .insert("color".to_owned(), Value::Number(Number::from(colour)));
self
}
@@ -106,20 +95,16 @@ impl EditRole {
/// Whether or not to make the role mentionable, notifying its users.
pub fn mentionable(mut self, mentionable: bool) -> Self {
- self.0.insert(
- "mentionable".to_owned(),
- Value::Bool(mentionable),
- );
+ self.0
+ .insert("mentionable".to_owned(), Value::Bool(mentionable));
self
}
/// The name of the role to set.
pub fn name(mut self, name: &str) -> Self {
- self.0.insert(
- "name".to_owned(),
- Value::String(name.to_owned()),
- );
+ self.0
+ .insert("name".to_owned(), Value::String(name.to_owned()));
self
}
@@ -137,10 +122,8 @@ impl EditRole {
/// The position to assign the role in the role list. This correlates to the
/// role's position in the user list.
pub fn position(mut self, position: u8) -> Self {
- self.0.insert(
- "position".to_owned(),
- Value::Number(Number::from(position)),
- );
+ self.0
+ .insert("position".to_owned(), Value::Number(Number::from(position)));
self
}
@@ -163,24 +146,12 @@ impl Default for EditRole {
let mut map = Map::new();
let permissions = Number::from(permissions::PRESET_GENERAL.bits());
- map.insert(
- "color".to_owned(),
- Value::Number(Number::from(10_070_709)),
- );
+ map.insert("color".to_owned(), Value::Number(Number::from(10_070_709)));
map.insert("hoist".to_owned(), Value::Bool(false));
map.insert("mentionable".to_owned(), Value::Bool(false));
- map.insert(
- "name".to_owned(),
- Value::String("new role".to_owned()),
- );
- map.insert(
- "permissions".to_owned(),
- Value::Number(permissions),
- );
- map.insert(
- "position".to_owned(),
- Value::Number(Number::from(1)),
- );
+ map.insert("name".to_owned(), Value::String("new role".to_owned()));
+ map.insert("permissions".to_owned(), Value::Number(permissions));
+ map.insert("position".to_owned(), Value::Number(Number::from(1)));
EditRole(map)
}
diff --git a/src/builder/execute_webhook.rs b/src/builder/execute_webhook.rs
index 05f0d00..0cb276c 100644
--- a/src/builder/execute_webhook.rs
+++ b/src/builder/execute_webhook.rs
@@ -103,10 +103,8 @@ impl ExecuteWebhook {
///
/// [`embeds`]: #method.embeds
pub fn content(mut self, content: &str) -> Self {
- self.0.insert(
- "content".to_owned(),
- Value::String(content.to_owned()),
- );
+ self.0
+ .insert("content".to_owned(), Value::String(content.to_owned()));
self
}
@@ -167,10 +165,8 @@ impl ExecuteWebhook {
/// }
/// ```
pub fn username(mut self, username: &str) -> Self {
- self.0.insert(
- "username".to_owned(),
- Value::String(username.to_owned()),
- );
+ self.0
+ .insert("username".to_owned(), Value::String(username.to_owned()));
self
}
diff --git a/src/builder/get_messages.rs b/src/builder/get_messages.rs
index 8ac5dfe..bca2f0e 100644
--- a/src/builder/get_messages.rs
+++ b/src/builder/get_messages.rs
@@ -85,10 +85,8 @@ impl GetMessages {
/// limitation. If an amount larger than 100 is supplied, it will be
/// reduced.
pub fn limit(mut self, limit: u64) -> Self {
- self.0.insert(
- "limit".to_owned(),
- if limit > 100 { 100 } else { limit },
- );
+ self.0
+ .insert("limit".to_owned(), if limit > 100 { 100 } else { limit });
self
}