diff options
| author | acdenisSK <[email protected]> | 2017-08-01 10:54:32 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-08-01 10:54:32 +0200 |
| commit | 3f9db73a3c193eecfac142ecc40c48d9e4140591 (patch) | |
| tree | 4e361f176e09319cd3b94c7896ee850b896c4dc6 /src | |
| parent | Provide the input and limit back to the user, and do some consistencies (diff) | |
| download | serenity-3f9db73a3c193eecfac142ecc40c48d9e4140591.tar.xz serenity-3f9db73a3c193eecfac142ecc40c48d9e4140591.zip | |
Clippy and rustfmt
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/mod.rs | 12 | ||||
| -rw-r--r-- | src/framework/mod.rs | 9 | ||||
| -rw-r--r-- | src/http/ratelimiting.rs | 3 | ||||
| -rw-r--r-- | src/internal/ws_impl.rs | 2 | ||||
| -rw-r--r-- | src/model/guild/audit_log.rs | 16 | ||||
| -rw-r--r-- | src/model/guild/member.rs | 2 |
6 files changed, 24 insertions, 20 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index f5382e2..69d3903 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -803,7 +803,11 @@ fn boot_shard(info: &BootInfo) -> Result<Shard> { // After three attempts, start re-retrieving the gateway URL. Before that, // use the cached one. for attempt_number in 1..3u64 { - let BootInfo { ref gateway_url, ref token, shard_info } = *info; + let BootInfo { + ref gateway_url, + ref token, + shard_info, + } = *info; // If we've tried over 3 times so far, get a new gateway URL. // // If doing so fails, count this as a boot attempt. @@ -819,11 +823,7 @@ fn boot_shard(info: &BootInfo) -> Result<Shard> { } } - let attempt = Shard::new( - gateway_url.clone(), - token.clone(), - shard_info, - ); + let attempt = Shard::new(gateway_url.clone(), token.clone(), shard_info); match attempt { Ok(shard) => { diff --git a/src/framework/mod.rs b/src/framework/mod.rs index bc6afbd..9206040 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -214,7 +214,6 @@ type DispatchErrorHook = Fn(Context, Message, DispatchError) + 'static; /// Refer to the [module-level documentation] for more information. /// /// [module-level documentation]: index.html -#[allow(type_complexity)] #[derive(Default)] pub struct BuiltinFramework { configuration: Configuration, @@ -518,13 +517,15 @@ impl BuiltinFramework { if let Some(ref mut bucket) = self.buckets.get_mut(bucket) { let rate_limit = bucket.take(message.author.id.0); match bucket.check { - Some(ref check) => if feature_cache! {{ + Some(ref check) => { + let apply = feature_cache! {{ let guild_id = message.guild_id(); (check)(context, guild_id, message.channel_id, message.author.id) } else { (check)(context, message.channel_id, message.author.id) - }} { - if rate_limit > 0i64 { + }}; + + if apply && rate_limit > 0i64 { return Some(DispatchError::RateLimited(rate_limit)); } }, diff --git a/src/http/ratelimiting.rs b/src/http/ratelimiting.rs index dad5f7e..f0eb8fc 100644 --- a/src/http/ratelimiting.rs +++ b/src/http/ratelimiting.rs @@ -370,7 +370,8 @@ pub(crate) fn perform<'a, F>(route: Route, f: F) -> Result<Response> remaining: i64::MAX, reset: i64::MAX, })) - }).clone(); + }) + .clone(); let mut lock = bucket.lock().unwrap(); lock.pre_hook(&route); diff --git a/src/internal/ws_impl.rs b/src/internal/ws_impl.rs index 2684f45..a80745d 100644 --- a/src/internal/ws_impl.rs +++ b/src/internal/ws_impl.rs @@ -44,7 +44,7 @@ impl ReceiverExt for WsClient<TlsStream<TcpStream>> { OwnedMessage::Ping(x) => { self.send_message(&OwnedMessage::Pong(x)) .map_err(Error::from)?; - + None }, OwnedMessage::Pong(_) => None, diff --git a/src/model/guild/audit_log.rs b/src/model/guild/audit_log.rs index 4d2988b..380bfa1 100644 --- a/src/model/guild/audit_log.rs +++ b/src/model/guild/audit_log.rs @@ -54,7 +54,9 @@ impl FromNum for Action { Ok(match num { 1 => Action::GuildUpdate, num if num >= 10 && num <= 13 => Action::Channel(ActionChannel::from_num(num)?), - num if num >= 13 && num <= 15 => Action::ChannelOverwrite(ActionChannelOverwrite::from_num(num)?), + num if num >= 13 && num <= 15 => { + Action::ChannelOverwrite(ActionChannelOverwrite::from_num(num)?) + }, num if num >= 20 && num <= 25 => Action::Member(ActionMember::from_num(num)?), num if num >= 30 && num <= 32 => Action::Role(ActionRole::from_num(num)?), num if num >= 40 && num <= 42 => Action::Invite(ActionInvite::from_num(num)?), @@ -62,7 +64,7 @@ impl FromNum for Action { num if num >= 60 && num <= 62 => Action::Emoji(ActionEmoji::from_num(num)?), _ => return Err(format!("Unexpected action number: {}", num)), }) - } + } } #[derive(Debug)] @@ -112,7 +114,7 @@ pub enum ActionMember { BanAdd, BanRemove, Update, - RoleUpdate + RoleUpdate, } impl FromNum for ActionMember { @@ -259,7 +261,7 @@ fn deserialize_target<'de, D: Deserializer<'de>>(de: D) -> Result<Target, D::Err } fn visit_i32<E: de::Error>(self, value: i32) -> Result<Target, E> { - Target::from_num(value).map_err(|e| E::custom(e)) + Target::from_num(value).map_err(E::custom) } } @@ -277,7 +279,7 @@ fn deserialize_action<'de, D: Deserializer<'de>>(de: D) -> Result<Action, D::Err } fn visit_i32<E: de::Error>(self, value: i32) -> Result<Action, E> { - Action::from_num(value).map_err(|e| E::custom(e)) + Action::from_num(value).map_err(E::custom) } } @@ -290,7 +292,7 @@ impl<'de> Deserialize<'de> for AuditLogs { #[serde(field_identifier)] enum Field { #[serde(rename = "audit_log_entries")] - AuditLogEntries, + Entries, } struct EntriesVisitor; @@ -304,7 +306,7 @@ impl<'de> Deserialize<'de> for AuditLogs { fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<AuditLogs, V::Error> { let audit_log_entries = loop { - if let Some(Field::AuditLogEntries) = map.next_key()? { + if let Some(Field::Entries) = map.next_key()? { break map.next_value::<Vec<AuditLogEntry>>()?; } }; diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index 756477b..38033e3 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -30,7 +30,7 @@ impl BanOptions for str { } impl BanOptions for String { - fn reason(&self) -> &str { &self } + fn reason(&self) -> &str { self } } impl<'a> BanOptions for (u8, &'a str) { |