diff options
| author | Mishio595 <[email protected]> | 2018-06-26 19:48:51 -0600 |
|---|---|---|
| committer | Mishio595 <[email protected]> | 2018-06-26 19:48:51 -0600 |
| commit | 1ed471305368c3fe345c02a101e3a772ba6e98e7 (patch) | |
| tree | bd4aa88580c659cb9e4ade0a28e93e34fe9b668b /src | |
| parent | Add CreateEmbed::Field/s to 11_create_message_builder example (#338) (diff) | |
| download | serenity-1ed471305368c3fe345c02a101e3a772ba6e98e7.tar.xz serenity-1ed471305368c3fe345c02a101e3a772ba6e98e7.zip | |
Add Colour::hex()
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/colour.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/colour.rs b/src/utils/colour.rs index 77a1ce7..81b6ee9 100644 --- a/src/utils/colour.rs +++ b/src/utils/colour.rs @@ -184,6 +184,20 @@ impl Colour { /// [`g`]: #method.g /// [`b`]: #method.b pub fn tuple(&self) -> (u8, u8, u8) { (self.r(), self.g(), self.b()) } + + /// Returns a hexadecimal string of this Colour. + /// + /// This is equivalent to passing the integer value through `std::fmt::UpperHex` with 0 padding + /// and 6 width + /// + /// # Examples + /// + /// ```rust + /// use serenity::utils::Colour; + /// + /// assert_eq!(Colour::new(6573123).hex(), String::from("644C43")); + /// ``` + pub fn hex(&self) -> String { format!("{:06X}", self.0) } } impl From<i32> for Colour { |