docs: place in the correct position
This commit is contained in:
parent
b00cac307a
commit
0e7b3925c5
1 changed files with 10 additions and 10 deletions
|
@ -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()))
|
||||
|
|
Loading…
Reference in a new issue