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/create_embed.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/create_embed.rs')
| -rw-r--r-- | src/builder/create_embed.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs index a128c91..7303693 100644 --- a/src/builder/create_embed.rs +++ b/src/builder/create_embed.rs @@ -62,14 +62,20 @@ impl CreateEmbed { /// [`colour`]: #method.colour #[cfg(feature = "utils")] #[inline] - pub fn color<C: Into<Colour>>(self, colour: C) -> Self { self.colour(colour.into()) } + pub fn color<C: Into<Colour>>(self, colour: C) -> Self { self.colour(colour) } + /// Set the colour of the left-hand side of the embed. #[cfg(feature = "utils")] pub fn colour<C: Into<Colour>>(mut self, colour: C) -> Self { + self._colour(colour.into()) + } + + #[cfg(feature = "utils")] + fn _colour(mut self, colour: Colour) -> Self { self.0.insert( "color".to_string(), - Value::Number(Number::from(colour.into().0 as u64)), + Value::Number(Number::from(colour.0 as u64)), ); CreateEmbed(self.0) @@ -282,8 +288,12 @@ impl CreateEmbed { /// let mut client = Client::new("token", Handler); client.start().unwrap(); /// ``` pub fn timestamp<T: Into<Timestamp>>(mut self, timestamp: T) -> Self { + self._timestamp(timestamp.into()) + } + + fn _timestamp(mut self, timestamp: Timestamp) -> Self { self.0 - .insert("timestamp".to_string(), Value::String(timestamp.into().ts)); + .insert("timestamp".to_string(), Value::String(timestamp.ts)); CreateEmbed(self.0) } |