docs: place in the correct position

This commit is contained in:
Nikita Revenco 2024-12-19 17:41:03 +00:00
parent b00cac307a
commit 0e7b3925c5

View file

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