diff options
| author | Mishio595 <[email protected]> | 2018-07-12 11:41:41 -0600 |
|---|---|---|
| committer | Mishio595 <[email protected]> | 2018-07-12 11:41:41 -0600 |
| commit | ccb154269d512e147457ebba70d56421841d6703 (patch) | |
| tree | 789957d8b89d4d22b22017938911a59b84097efb /src/utils/colour.rs | |
| parent | Add checks for groups (diff) | |
| download | serenity-group-checks.tar.xz serenity-group-checks.zip | |
revert some bad changesgroup-checks
Diffstat (limited to 'src/utils/colour.rs')
| -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 3b31572..cac3d46 100644 --- a/src/utils/colour.rs +++ b/src/utils/colour.rs @@ -190,6 +190,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 { |