diff options
| author | Zeyla Hellyer <[email protected]> | 2017-08-18 16:14:32 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-08-18 17:52:53 -0700 |
| commit | e4113570967a1fb13539efbfa2cf7285b19d95ba (patch) | |
| tree | 06bb020fcfaa5f8323454dfb525272314a900186 /src/builder | |
| parent | Move Clippy lints to a cfg_attr (diff) | |
| download | serenity-e4113570967a1fb13539efbfa2cf7285b19d95ba.tar.xz serenity-e4113570967a1fb13539efbfa2cf7285b19d95ba.zip | |
Apply rustfmt
Diffstat (limited to 'src/builder')
| -rw-r--r-- | src/builder/create_embed.rs | 71 | ||||
| -rw-r--r-- | src/builder/create_invite.rs | 18 | ||||
| -rw-r--r-- | src/builder/create_message.rs | 6 | ||||
| -rw-r--r-- | src/builder/edit_channel.rs | 24 | ||||
| -rw-r--r-- | src/builder/edit_guild.rs | 17 | ||||
| -rw-r--r-- | src/builder/edit_member.rs | 6 | ||||
| -rw-r--r-- | src/builder/edit_profile.rs | 18 | ||||
| -rw-r--r-- | src/builder/edit_role.rs | 61 | ||||
| -rw-r--r-- | src/builder/execute_webhook.rs | 12 | ||||
| -rw-r--r-- | src/builder/get_messages.rs | 6 |
10 files changed, 165 insertions, 74 deletions
diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs index 1e0bc8d..6d61653 100644 --- a/src/builder/create_embed.rs +++ b/src/builder/create_embed.rs @@ -87,8 +87,10 @@ 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) } @@ -282,24 +284,30 @@ 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) } @@ -319,7 +327,10 @@ 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) } @@ -396,24 +407,30 @@ 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 } @@ -440,16 +457,20 @@ 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 } @@ -479,16 +500,20 @@ 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 58893fc..d17f273 100644 --- a/src/builder/create_invite.rs +++ b/src/builder/create_invite.rs @@ -89,8 +89,10 @@ 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 } @@ -123,8 +125,10 @@ 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 } @@ -155,8 +159,10 @@ 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 dea77e1..1ac5211 100644 --- a/src/builder/create_message.rs +++ b/src/builder/create_message.rs @@ -46,8 +46,10 @@ 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 e3bf78e..a5d799f 100644 --- a/src/builder/edit_channel.rs +++ b/src/builder/edit_channel.rs @@ -27,8 +27,10 @@ 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 } @@ -37,16 +39,20 @@ 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 } @@ -59,8 +65,10 @@ 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 f88db2a..6cfd13a 100644 --- a/src/builder/edit_guild.rs +++ b/src/builder/edit_guild.rs @@ -79,7 +79,10 @@ 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 @@ -89,8 +92,10 @@ 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 } @@ -134,8 +139,10 @@ 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 23bf1f2..80ec983 100644 --- a/src/builder/edit_member.rs +++ b/src/builder/edit_member.rs @@ -39,8 +39,10 @@ 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 6aa4e78..3bc121c 100644 --- a/src/builder/edit_profile.rs +++ b/src/builder/edit_profile.rs @@ -61,8 +61,10 @@ 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 } @@ -88,8 +90,10 @@ 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 } @@ -101,8 +105,10 @@ 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 bece07c..9ac98d7 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, Permissions, Role}; +use model::{Permissions, Role, permissions}; /// A builer to create or edit a [`Role`] for use via a number of model methods. /// @@ -58,13 +58,22 @@ 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())), @@ -79,8 +88,10 @@ 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 } @@ -95,16 +106,20 @@ 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 } @@ -122,8 +137,10 @@ 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 } @@ -146,12 +163,24 @@ 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(10070709))); + map.insert( + "color".to_owned(), + Value::Number(Number::from(10070709)), + ); 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 0cb276c..05f0d00 100644 --- a/src/builder/execute_webhook.rs +++ b/src/builder/execute_webhook.rs @@ -103,8 +103,10 @@ 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 } @@ -165,8 +167,10 @@ 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 bca2f0e..8ac5dfe 100644 --- a/src/builder/get_messages.rs +++ b/src/builder/get_messages.rs @@ -85,8 +85,10 @@ 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 } |