docs: add doc for from_hex

This commit is contained in:
Nikita Revenco 2024-12-19 17:37:44 +00:00
parent aed0f8d1f8
commit 6617f1209c

View file

@ -263,6 +263,16 @@ pub enum Color {
Indexed(u8),
}
/// Creates a `Color` from a hex string
///
/// # Examples
///
/// ```rust
/// let color1 = Color::from_hex("#c0ffee");
/// let color2 = Color::Rgb(192, 255, 238);
///
/// assert_eq!(color1, color2);
/// ```
impl Color {
pub fn from_hex(hex: &str) -> Option<Self> {
match [1..=2, 3..=4, 5..=6]