aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMishio595 <[email protected]>2018-07-24 16:33:55 -0600
committerMishio595 <[email protected]>2018-07-24 16:33:55 -0600
commit6c94e05f6a8de131d0ffc913fd6ccbad602b339e (patch)
treefbb847dde6b5d4bd678d35bddacb9533410a5f79
parentFallback to default-command if passed sub-command is wrong (diff)
downloadserenity-colour_hex.tar.xz
serenity-colour_hex.zip
add method Colour::hexcolour_hex
-rw-r--r--src/utils/colour.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils/colour.rs b/src/utils/colour.rs
index c901e9b..b5c2e05 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 {