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/group.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/group.rs')
| -rw-r--r-- | src/model/channel/group.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs index 7007ad6..94483ec 100644 --- a/src/model/channel/group.rs +++ b/src/model/channel/group.rs @@ -1,5 +1,6 @@ use chrono::{DateTime, FixedOffset}; use model::*; +use internal::RwLockExt; #[cfg(feature = "model")] use std::borrow::Cow; @@ -123,11 +124,8 @@ impl Group { reaction_type: R) -> Result<()> where M: Into<MessageId>, R: Into<ReactionType> { - self.channel_id.delete_reaction( - message_id, - user_id, - reaction_type, - ) + self.channel_id + .delete_reaction(message_id, user_id, reaction_type) } /// Edits a [`Message`] in the channel given its Id. @@ -208,12 +206,12 @@ impl Group { Some(ref name) => Cow::Borrowed(name), None => { let mut name = match self.recipients.values().nth(0) { - Some(recipient) => recipient.read().unwrap().name.clone(), + Some(recipient) => recipient.with(|c| c.name.clone()), None => return Cow::Borrowed("Empty Group"), }; for recipient in self.recipients.values().skip(1) { - let _ = write!(name, ", {}", recipient.read().unwrap().name); + let _ = write!(name, ", {}", recipient.with(|r| r.name.clone())); } Cow::Owned(name) @@ -245,12 +243,8 @@ impl Group { after: Option<U>) -> Result<Vec<User>> where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> { - self.channel_id.reaction_users( - message_id, - reaction_type, - limit, - after, - ) + self.channel_id + .reaction_users(message_id, reaction_type, limit, after) } /// Removes a recipient from the group. If the recipient is already not in @@ -315,7 +309,7 @@ impl Group { /// [`CreateMessage`]: ../builder/struct.CreateMessage.html /// [Send Messages]: permissions/constant.SEND_MESSAGES.html #[inline] - pub fn send_message<F: FnOnce(CreateMessage) -> CreateMessage>(&self, f: F) -> Result<Message> { +pub fn send_message<F: FnOnce(CreateMessage) -> CreateMessage>(&self, f: F) -> Result<Message>{ self.channel_id.send_message(f) } |