diff options
| author | acdenisSK <[email protected]> | 2017-10-02 22:29:10 +0200 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-10-09 15:47:05 -0700 |
| commit | 2911f677431820ac858bae39ce53a3d6e202da1b (patch) | |
| tree | 1a65a208341e2a8006807f96074ca17cd0aaaed8 /src/builder/get_messages.rs | |
| parent | `to_owned` -> `to_string` (diff) | |
| download | serenity-2911f677431820ac858bae39ce53a3d6e202da1b.tar.xz serenity-2911f677431820ac858bae39ce53a3d6e202da1b.zip | |
Use the de-generification trick.
Fixes #168
Diffstat (limited to 'src/builder/get_messages.rs')
| -rw-r--r-- | src/builder/get_messages.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/builder/get_messages.rs b/src/builder/get_messages.rs index 71af9e5..eff90f4 100644 --- a/src/builder/get_messages.rs +++ b/src/builder/get_messages.rs @@ -55,24 +55,36 @@ pub struct GetMessages(pub BTreeMap<String, u64>); impl GetMessages { /// Indicates to retrieve the messages after a specific message, given by /// its Id. - pub fn after<M: Into<MessageId>>(mut self, message_id: M) -> Self { - self.0.insert("after".to_string(), message_id.into().0); + pub fn after<M: Into<MessageId>>(self, message_id: M) -> Self { + self._after(message_id.into()) + } + + fn _after(mut self, MessageId(id): MessageId) -> Self { + self.0.insert("after".to_string(), id); self } /// Indicates to retrieve the messages _around_ a specific message in either /// direction (before+after) the given message. - pub fn around<M: Into<MessageId>>(mut self, message_id: M) -> Self { - self.0.insert("around".to_string(), message_id.into().0); + pub fn around<M: Into<MessageId>>(self, message_id: M) -> Self { + self._around(message_id.into()) + } + + fn _around(mut self, MessageId(id): MessageId) -> Self { + self.0.insert("around".to_string(), id); self } /// Indicates to retrieve the messages before a specific message, given by /// its Id. - pub fn before<M: Into<MessageId>>(mut self, message_id: M) -> Self { - self.0.insert("before".to_string(), message_id.into().0); + pub fn before<M: Into<MessageId>>(self, message_id: M) -> Self { + self._before(message_id.into()) + } + + fn _before(mut self, MessageId(id): MessageId) -> Self { + self.0.insert("before".to_string(), id); self } |