diff options
| author | acdenisSK <[email protected]> | 2017-08-24 15:26:49 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-08-24 16:36:01 +0200 |
| commit | b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3 (patch) | |
| tree | 315e16f7b252d22b5f832302e722a85c9e6a9b6e /src/model/channel/message.rs | |
| parent | Allow FromStr for User to use REST (#147) (diff) | |
| download | serenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.tar.xz serenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.zip | |
Revamp `RwLock` usage in the lib
Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
Diffstat (limited to 'src/model/channel/message.rs')
| -rw-r--r-- | src/model/channel/message.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index 27f4e31..399d351 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -291,10 +291,9 @@ impl Message { } // And finally replace everyone and here mentions. - result.replace("@everyone", "@\u{200B}everyone").replace( - "@here", - "@\u{200B}here", - ) + result + .replace("@everyone", "@\u{200B}everyone") + .replace("@here", "@\u{200B}here") } /// Gets the list of [`User`]s who have reacted to a [`Message`] with a @@ -320,12 +319,8 @@ impl Message { after: Option<U>) -> Result<Vec<User>> where R: Into<ReactionType>, U: Into<UserId> { - self.channel_id.reaction_users( - self.id, - reaction_type, - limit, - after, - ) + self.channel_id + .reaction_users(self.id, reaction_type, limit, after) } /// Returns the associated `Guild` for the message if one is in the cache. @@ -338,9 +333,8 @@ impl Message { /// [`guild_id`]: #method.guild_id #[cfg(feature = "cache")] pub fn guild(&self) -> Option<Arc<RwLock<Guild>>> { - self.guild_id().and_then(|guild_id| { - CACHE.read().unwrap().guild(guild_id) - }) + self.guild_id() + .and_then(|guild_id| CACHE.read().unwrap().guild(guild_id)) } /// Retrieves the Id of the guild that the message was sent in, if sent in @@ -360,8 +354,7 @@ impl Message { #[cfg(feature = "cache")] pub fn is_private(&self) -> bool { match CACHE.read().unwrap().channel(self.channel_id) { - Some(Channel::Group(_)) | - Some(Channel::Private(_)) => true, + Some(Channel::Group(_)) | Some(Channel::Private(_)) => true, _ => false, } } @@ -378,7 +371,11 @@ impl Message { let count = content.chars().count() as i64; let diff = count - (constants::MESSAGE_CODE_LIMIT as i64); - if diff > 0 { Some(diff as u64) } else { None } + if diff > 0 { + Some(diff as u64) + } else { + None + } } /// Pins this message to its channel. |