diff options
| author | acdenisSK <[email protected]> | 2017-10-02 22:29:10 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-10-02 22:29:10 +0200 |
| commit | 6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249 (patch) | |
| tree | ae9ad7d7cb73d4ece6a199796af5975545071493 /src/builder/get_messages.rs | |
| parent | `to_owned` -> `to_string` (diff) | |
| download | serenity-6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249.tar.xz serenity-6a4e52b3fac7d2e96e3a1a67901fbdd4721fb249.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 } |