| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/, envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/, strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#}; |
| 2 | use Colorrust-analyzer cargo colored 3.1.1 color/Color#::{ |
| 3 | AnsiColorrust-analyzer cargo colored 3.1.1 color/Color#AnsiColor#, Blackrust-analyzer cargo colored 3.1.1 color/Color#Black#, Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack#, BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue#, BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan#, BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen#, BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta#, |
| 4 | BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed#, BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite#, BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow#, Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan#, Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#, Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#, Redrust-analyzer cargo colored 3.1.1 color/Color#Red#, TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#, Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow#, |
| 5 | }; |
| 6 | |
| 7 | /// The 8 standard colors. |
| 8 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 9 | #[allow(missing_docs)] |
| 10 | pub enum Colorrust-analyzer cargo colored 3.1.1 color/Color# { |
| 11 | Blackrust-analyzer cargo colored 3.1.1 color/Color#Black#, |
| 12 | Redrust-analyzer cargo colored 3.1.1 color/Color#Red#, |
| 13 | Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#, |
| 14 | Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow#, |
| 15 | Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 16 | Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#, |
| 17 | Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan#, |
| 18 | Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 19 | BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack#, |
| 20 | BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed#, |
| 21 | BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen#, |
| 22 | BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow#, |
| 23 | BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue#, |
| 24 | BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta#, |
| 25 | BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan#, |
| 26 | BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite#, |
| 27 | AnsiColorrust-analyzer cargo colored 3.1.1 color/Color#AnsiColor#(u8), |
| 28 | TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: u8, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: u8, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: u8 }, |
| 29 | } |
| 30 | |
| 31 | fn truecolor_supportrust-analyzer cargo colored 3.1.1 color/truecolor_support().() -> bool { |
| 32 | let truecolor = envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("COLORTERM"); |
| 33 | truecolor.is_ok_andrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok_and().(|truecolor| truecolor rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."truecolor" || truecolor rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."24bit") |
| 34 | } |
| 35 | |
| 36 | #[allow(missing_docs)] |
| 37 | impl Colorrust-analyzer cargo colored 3.1.1 color/Color# { |
| 38 | #[must_use] |
| 39 | pub fn to_fg_strrust-analyzer cargo colored 3.1.1 color/impl#[Color]to_fg_str().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 40 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 41 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Blackrust-analyzer cargo colored 3.1.1 color/Color#Black# => "30".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 42 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Redrust-analyzer cargo colored 3.1.1 color/Color#Red# => "31".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 43 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green# => "32".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 44 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow# => "33".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 45 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue# => "34".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 46 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta# => "35".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 47 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan# => "36".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 48 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Whiterust-analyzer cargo colored 3.1.1 color/Color#White# => "37".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 49 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack# => "90".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 50 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed# => "91".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 51 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen# => "92".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 52 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow# => "93".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 53 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue# => "94".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 54 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta# => "95".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 55 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan# => "96".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 56 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite# => "97".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 57 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { .. } if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().truecolor_supportrust-analyzer cargo colored 3.1.1 color/truecolor_support().() => { |
| 58 | self.closest_color_euclideanrust-analyzer cargo colored 3.1.1 color/impl#[Color]closest_color_euclidean().().to_fg_strrust-analyzer cargo colored 3.1.1 color/impl#[Color]to_fg_str().() |
| 59 | } |
| 60 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::AnsiColorrust-analyzer cargo colored 3.1.1 color/Color#AnsiColor#(code) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("38;5;{code}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 61 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r., grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g., brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b. } => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("38;2;{r};{g};{b}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | #[must_use] |
| 66 | pub fn to_bg_strrust-analyzer cargo colored 3.1.1 color/impl#[Color]to_bg_str().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 67 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 68 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Blackrust-analyzer cargo colored 3.1.1 color/Color#Black# => "40".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 69 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Redrust-analyzer cargo colored 3.1.1 color/Color#Red# => "41".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 70 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green# => "42".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 71 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow# => "43".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 72 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue# => "44".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 73 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta# => "45".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 74 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan# => "46".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 75 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::Whiterust-analyzer cargo colored 3.1.1 color/Color#White# => "47".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 76 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack# => "100".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 77 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed# => "101".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 78 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen# => "102".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 79 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow# => "103".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 80 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue# => "104".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 81 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta# => "105".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 82 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan# => "106".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 83 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite# => "107".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 84 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::AnsiColorrust-analyzer cargo colored 3.1.1 color/Color#AnsiColor#(code) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("48;5;{code}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 85 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { .. } if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().truecolor_supportrust-analyzer cargo colored 3.1.1 color/truecolor_support().() => { |
| 86 | self.closest_color_euclideanrust-analyzer cargo colored 3.1.1 color/impl#[Color]closest_color_euclidean().().to_bg_strrust-analyzer cargo colored 3.1.1 color/impl#[Color]to_bg_str().() |
| 87 | } |
| 88 | Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color]::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r., grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g., brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b. } => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("48;2;{r};{g};{b}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /// Gets the closest plain color to the `TrueColor` |
| 93 | fn closest_color_euclideanrust-analyzer cargo colored 3.1.1 color/impl#[Color]closest_color_euclidean().(self) -> Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color] { |
| 94 | match self { |
| 95 | TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 96 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: r1, |
| 97 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: g1, |
| 98 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: b1, |
| 99 | } => { |
| 100 | let colors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 101 | Blackrust-analyzer cargo colored 3.1.1 color/Color#Black#, |
| 102 | Redrust-analyzer cargo colored 3.1.1 color/Color#Red#, |
| 103 | Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#, |
| 104 | Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow#, |
| 105 | Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 106 | Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#, |
| 107 | Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan#, |
| 108 | Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 109 | BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack#, |
| 110 | BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed#, |
| 111 | BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen#, |
| 112 | BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow#, |
| 113 | BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue#, |
| 114 | BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta#, |
| 115 | BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan#, |
| 116 | BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite#, |
| 117 | ] |
| 118 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 119 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| (c, c.into_truecolorrust-analyzer cargo colored 3.1.1 color/impl#[Color]into_truecolor().())); |
| 120 | let distances = colors.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(c_original, c)| { |
| 121 | if let TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r., grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g., brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b. } = c { |
| 122 | let rd = cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(r, r1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(r, r1); |
| 123 | let gd = cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(g, g1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(g, g1); |
| 124 | let bd = cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(b, b1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(b, b1); |
| 125 | let rd: u32 = rd.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 126 | let gd: u32 = gd.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 127 | let bd: u32 = bd.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 128 | let distance = rd.powrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]pow().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().gd.powrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]pow().(2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().bd.powrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]pow().(2); |
| 129 | (c_original, distance) |
| 130 | } else { |
| 131 | unimplementedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unimplemented!!("{:?} not a TrueColor", c) |
| 132 | } |
| 133 | }); |
| 134 | distances.min_byrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#min_by().(|(_, d1), (_, d2)| d1.cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][Ord]cmp().(d2)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().0 |
| 135 | } |
| 136 | c => c, |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | const fn into_truecolorrust-analyzer cargo colored 3.1.1 color/impl#[Color]into_truecolor().(self) -> Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color] { |
| 141 | match self { |
| 142 | Blackrust-analyzer cargo colored 3.1.1 color/Color#Black# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 0, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 0, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 0 }, |
| 143 | Redrust-analyzer cargo colored 3.1.1 color/Color#Red# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 205, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 0, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 0 }, |
| 144 | Greenrust-analyzer cargo colored 3.1.1 color/Color#Green# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 0, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 0 }, |
| 145 | Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 146 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 205, |
| 147 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, |
| 148 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 0, |
| 149 | }, |
| 150 | Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 0, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 0, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 238 }, |
| 151 | Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 152 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 205, |
| 153 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 0, |
| 154 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 205, |
| 155 | }, |
| 156 | Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 157 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 0, |
| 158 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, |
| 159 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 205, |
| 160 | }, |
| 161 | Whiterust-analyzer cargo colored 3.1.1 color/Color#White# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 162 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 229, |
| 163 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 229, |
| 164 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 229, |
| 165 | }, |
| 166 | BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 167 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 127, |
| 168 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 127, |
| 169 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 127, |
| 170 | }, |
| 171 | BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 255, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 0, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 0 }, |
| 172 | BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 0, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 255, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 0 }, |
| 173 | BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 174 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 255, |
| 175 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 255, |
| 176 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 0, |
| 177 | }, |
| 178 | BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 179 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 92, |
| 180 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 92, |
| 181 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 255, |
| 182 | }, |
| 183 | BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 184 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 255, |
| 185 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 0, |
| 186 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 255, |
| 187 | }, |
| 188 | BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 189 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 0, |
| 190 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 255, |
| 191 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 255, |
| 192 | }, |
| 193 | BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite# => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { |
| 194 | rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 255, |
| 195 | grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 255, |
| 196 | brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 255, |
| 197 | }, |
| 198 | AnsiColorrust-analyzer cargo colored 3.1.1 color/Color#AnsiColor#(color) => AnsiColorrust-analyzer cargo colored 3.1.1 color/Color#AnsiColor#(color), |
| 199 | TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r., grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g., brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b. } => TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r., grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g., brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b. }, |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&str> for Colorrust-analyzer cargo colored 3.1.1 color/Color# { |
| 205 | fn fromrust-analyzer cargo colored 3.1.1 color/impl#[Color][`From<&str>`]from().(src: &str) -> Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][`From<&str>`] { |
| 206 | src.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][`From<&str>`]::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#) |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Colorrust-analyzer cargo colored 3.1.1 color/Color# { |
| 211 | fn fromrust-analyzer cargo colored 3.1.1 color/impl#[Color][`From<String>`]from().(src: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][`From<String>`] { |
| 212 | src.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][`From<String>`]::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#) |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Colorrust-analyzer cargo colored 3.1.1 color/Color# { |
| 217 | type Errrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]Err# = (); |
| 218 | |
| 219 | fn from_strrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]from_str().(src: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr], Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 220 | let src = src.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().(); |
| 221 | |
| 222 | match src.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().() { |
| 223 | "black" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Blackrust-analyzer cargo colored 3.1.1 color/Color#Black#), |
| 224 | "red" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Redrust-analyzer cargo colored 3.1.1 color/Color#Red#), |
| 225 | "green" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#), |
| 226 | "yellow" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow#), |
| 227 | "blue" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#), |
| 228 | "magenta" | "purple" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#), |
| 229 | "cyan" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan#), |
| 230 | "white" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#), |
| 231 | "bright black" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack#), |
| 232 | "bright red" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed#), |
| 233 | "bright green" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen#), |
| 234 | "bright yellow" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow#), |
| 235 | "bright blue" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue#), |
| 236 | "bright magenta" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta#), |
| 237 | "bright cyan" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan#), |
| 238 | "bright white" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo colored 3.1.1 color/impl#[Color][FromStr]::BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite#), |
| 239 | s if s.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('#') => parse_hexrust-analyzer cargo colored 3.1.1 color/parse_hex().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(()), |
| 240 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | fn parse_hexrust-analyzer cargo colored 3.1.1 color/parse_hex().(s: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Colorrust-analyzer cargo colored 3.1.1 color/Color#> { |
| 246 | if s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().6 { |
| 247 | let r = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 248 | let g = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 249 | let b = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 250 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r., grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g., brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b. }) |
| 251 | } else if s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().3 { |
| 252 | let r = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 253 | let r = r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().(r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().4); |
| 254 | let g = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 255 | let g = g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().(g rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().4); |
| 256 | let b = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 257 | let b = b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().(b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().4); |
| 258 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r., grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g., brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b. }) |
| 259 | } else { |
| 260 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | #[cfg(test)] |
| 265 | mod testsrust-analyzer cargo colored 3.1.1 color/tests/ { |
| 266 | pub use superrust-analyzer cargo colored 3.1.1 color/::*; |
| 267 | |
| 268 | mod from_strrust-analyzer cargo colored 3.1.1 color/tests/from_str/ { |
| 269 | pub use superrust-analyzer cargo colored 3.1.1 color/tests/::*; |
| 270 | |
| 271 | macro_rules! make_testrust-analyzer cargo colored 3.1.1 color/tests/from_str/make_test! { |
| 272 | ( $( $name:ident: $src:expr => $dst:expr),* ) => { |
| 273 | |
| 274 | $( |
| 275 | #[test] |
| 276 | fn $name() { |
| 277 | let color : Color = $src.into(); |
| 278 | assert_eq!($dst, color) |
| 279 | } |
| 280 | )* |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | make_testrust-analyzer cargo colored 3.1.1 color/tests/from_str/make_test!!( |
| 285 | blackrust-analyzer cargo colored 3.1.1 color/tests/from_str/black().: "black" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Blackrust-analyzer cargo colored 3.1.1 color/Color#Black#, |
| 286 | redrust-analyzer cargo colored 3.1.1 color/tests/from_str/red().: "red" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Redrust-analyzer cargo colored 3.1.1 color/Color#Red#, |
| 287 | greenrust-analyzer cargo colored 3.1.1 color/tests/from_str/green().: "green" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#, |
| 288 | yellowrust-analyzer cargo colored 3.1.1 color/tests/from_str/yellow().: "yellow" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow#, |
| 289 | bluerust-analyzer cargo colored 3.1.1 color/tests/from_str/blue().: "blue" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 290 | magentarust-analyzer cargo colored 3.1.1 color/tests/from_str/magenta().: "magenta" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#, |
| 291 | purplerust-analyzer cargo colored 3.1.1 color/tests/from_str/purple().: "purple" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#, |
| 292 | cyanrust-analyzer cargo colored 3.1.1 color/tests/from_str/cyan().: "cyan" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan#, |
| 293 | whiterust-analyzer cargo colored 3.1.1 color/tests/from_str/white().: "white" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 294 | brightblackrust-analyzer cargo colored 3.1.1 color/tests/from_str/brightblack().: "bright black" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack#, |
| 295 | brightredrust-analyzer cargo colored 3.1.1 color/tests/from_str/brightred().: "bright red" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed#, |
| 296 | brightgreenrust-analyzer cargo colored 3.1.1 color/tests/from_str/brightgreen().: "bright green" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen#, |
| 297 | brightyellowrust-analyzer cargo colored 3.1.1 color/tests/from_str/brightyellow().: "bright yellow" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow#, |
| 298 | brightbluerust-analyzer cargo colored 3.1.1 color/tests/from_str/brightblue().: "bright blue" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue#, |
| 299 | brightmagentarust-analyzer cargo colored 3.1.1 color/tests/from_str/brightmagenta().: "bright magenta" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta#, |
| 300 | brightcyanrust-analyzer cargo colored 3.1.1 color/tests/from_str/brightcyan().: "bright cyan" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan#, |
| 301 | brightwhiterust-analyzer cargo colored 3.1.1 color/tests/from_str/brightwhite().: "bright white" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite#, |
| 302 | |
| 303 | invalidrust-analyzer cargo colored 3.1.1 color/tests/from_str/invalid().: "invalid" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 304 | capitalizedrust-analyzer cargo colored 3.1.1 color/tests/from_str/capitalized().: "BLUE" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 305 | mixed_caserust-analyzer cargo colored 3.1.1 color/tests/from_str/mixed_case().: "bLuE" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 306 | |
| 307 | hex3_lowerrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex3_lower().: "#abc" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 170, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 187, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 204 }, |
| 308 | hex3_upperrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex3_upper().: "#ABC" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 170, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 187, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 204 }, |
| 309 | hex3_mixedrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex3_mixed().: "#aBc" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 170, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 187, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 204 }, |
| 310 | hex6_lowerrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex6_lower().: "#abcdef" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 171, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 239 }, |
| 311 | hex6_upperrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex6_upper().: "#ABCDEF" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 171, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 239 }, |
| 312 | hex6_mixedrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex6_mixed().: "#aBcDeF" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 171, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 239 }, |
| 313 | hex_too_shortrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex_too_short().: "#aa" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 314 | hex_too_longrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex_too_long().: "#aaabbbccc" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 315 | hex_invalidrust-analyzer cargo colored 3.1.1 color/tests/from_str/hex_invalid().: "#abcxyz" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White# |
| 316 | ); |
| 317 | } |
| 318 | |
| 319 | mod from_stringrust-analyzer cargo colored 3.1.1 color/tests/from_string/ { |
| 320 | pub use superrust-analyzer cargo colored 3.1.1 color/tests/::*; |
| 321 | |
| 322 | macro_rules! make_testrust-analyzer cargo colored 3.1.1 color/tests/from_string/make_test! { |
| 323 | ( $( $name:ident: $src:expr => $dst:expr),* ) => { |
| 324 | |
| 325 | $( |
| 326 | #[test] |
| 327 | fn $name() { |
| 328 | let src = String::from($src); |
| 329 | let color : Color = src.into(); |
| 330 | assert_eq!($dst, color) |
| 331 | } |
| 332 | )* |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | make_testrust-analyzer cargo colored 3.1.1 color/tests/from_string/make_test!!( |
| 337 | blackrust-analyzer cargo colored 3.1.1 color/tests/from_string/black().: "black" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Blackrust-analyzer cargo colored 3.1.1 color/Color#Black#, |
| 338 | redrust-analyzer cargo colored 3.1.1 color/tests/from_string/red().: "red" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Redrust-analyzer cargo colored 3.1.1 color/Color#Red#, |
| 339 | greenrust-analyzer cargo colored 3.1.1 color/tests/from_string/green().: "green" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green#, |
| 340 | yellowrust-analyzer cargo colored 3.1.1 color/tests/from_string/yellow().: "yellow" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow#, |
| 341 | bluerust-analyzer cargo colored 3.1.1 color/tests/from_string/blue().: "blue" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 342 | magentarust-analyzer cargo colored 3.1.1 color/tests/from_string/magenta().: "magenta" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta#, |
| 343 | cyanrust-analyzer cargo colored 3.1.1 color/tests/from_string/cyan().: "cyan" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan#, |
| 344 | whiterust-analyzer cargo colored 3.1.1 color/tests/from_string/white().: "white" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 345 | brightblackrust-analyzer cargo colored 3.1.1 color/tests/from_string/brightblack().: "bright black" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightBlackrust-analyzer cargo colored 3.1.1 color/Color#BrightBlack#, |
| 346 | brightredrust-analyzer cargo colored 3.1.1 color/tests/from_string/brightred().: "bright red" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightRedrust-analyzer cargo colored 3.1.1 color/Color#BrightRed#, |
| 347 | brightgreenrust-analyzer cargo colored 3.1.1 color/tests/from_string/brightgreen().: "bright green" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightGreenrust-analyzer cargo colored 3.1.1 color/Color#BrightGreen#, |
| 348 | brightyellowrust-analyzer cargo colored 3.1.1 color/tests/from_string/brightyellow().: "bright yellow" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightYellowrust-analyzer cargo colored 3.1.1 color/Color#BrightYellow#, |
| 349 | brightbluerust-analyzer cargo colored 3.1.1 color/tests/from_string/brightblue().: "bright blue" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightBluerust-analyzer cargo colored 3.1.1 color/Color#BrightBlue#, |
| 350 | brightmagentarust-analyzer cargo colored 3.1.1 color/tests/from_string/brightmagenta().: "bright magenta" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightMagentarust-analyzer cargo colored 3.1.1 color/Color#BrightMagenta#, |
| 351 | brightcyanrust-analyzer cargo colored 3.1.1 color/tests/from_string/brightcyan().: "bright cyan" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightCyanrust-analyzer cargo colored 3.1.1 color/Color#BrightCyan#, |
| 352 | brightwhiterust-analyzer cargo colored 3.1.1 color/tests/from_string/brightwhite().: "bright white" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::BrightWhiterust-analyzer cargo colored 3.1.1 color/Color#BrightWhite#, |
| 353 | |
| 354 | invalidrust-analyzer cargo colored 3.1.1 color/tests/from_string/invalid().: "invalid" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 355 | capitalizedrust-analyzer cargo colored 3.1.1 color/tests/from_string/capitalized().: "BLUE" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 356 | mixed_caserust-analyzer cargo colored 3.1.1 color/tests/from_string/mixed_case().: "bLuE" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#, |
| 357 | |
| 358 | hex3_lowerrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex3_lower().: "#abc" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 170, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 187, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 204 }, |
| 359 | hex3_upperrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex3_upper().: "#ABC" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 170, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 187, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 204 }, |
| 360 | hex3_mixedrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex3_mixed().: "#aBc" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 170, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 187, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 204 }, |
| 361 | hex6_lowerrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex6_lower().: "#abcdef" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 171, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 239 }, |
| 362 | hex6_upperrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex6_upper().: "#ABCDEF" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 171, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 239 }, |
| 363 | hex6_mixedrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex6_mixed().: "#aBcDeF" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::TrueColorrust-analyzer cargo colored 3.1.1 color/Color#TrueColor# { rrust-analyzer cargo colored 3.1.1 color/Color#TrueColor#r.: 171, grust-analyzer cargo colored 3.1.1 color/Color#TrueColor#g.: 205, brust-analyzer cargo colored 3.1.1 color/Color#TrueColor#b.: 239 }, |
| 364 | hex_too_shortrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex_too_short().: "#aa" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 365 | hex_too_longrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex_too_long().: "#aaabbbccc" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White#, |
| 366 | hex_invalidrust-analyzer cargo colored 3.1.1 color/tests/from_string/hex_invalid().: "#abcxyz" => Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White# |
| 367 | ); |
| 368 | } |
| 369 | |
| 370 | mod fromstrrust-analyzer cargo colored 3.1.1 color/tests/fromstr/ { |
| 371 | pub use superrust-analyzer cargo colored 3.1.1 color/tests/::*; |
| 372 | |
| 373 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 374 | fn parserust-analyzer cargo colored 3.1.1 color/tests/fromstr/parse().() { |
| 375 | let color: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Colorrust-analyzer cargo colored 3.1.1 color/Color#, _> = "blue".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(); |
| 376 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue#), color); |
| 377 | } |
| 378 | |
| 379 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 380 | fn errorrust-analyzer cargo colored 3.1.1 color/tests/fromstr/error().() { |
| 381 | let color: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Colorrust-analyzer cargo colored 3.1.1 color/Color#, ()> = "bloublou".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(); |
| 382 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), color); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | mod closest_euclideanrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/ { |
| 387 | use superrust-analyzer cargo colored 3.1.1 color/tests/::*; |
| 388 | |
| 389 | macro_rules! make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test! { |
| 390 | ( $test:ident : ( $r:literal, $g: literal, $b:literal ), $expected:expr ) => { |
| 391 | #[test] |
| 392 | fn $test() { |
| 393 | let true_color = Color::TrueColor { |
| 394 | r: $r, |
| 395 | g: $g, |
| 396 | b: $b, |
| 397 | }; |
| 398 | let actual = true_color.closest_color_euclidean(); |
| 399 | assert_eq!(actual, $expected); |
| 400 | } |
| 401 | }; |
| 402 | } |
| 403 | |
| 404 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_blackrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_black().: (0, 0, 0), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Blackrust-analyzer cargo colored 3.1.1 color/Color#Black# } |
| 405 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_redrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_red().: (205, 0, 0), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Redrust-analyzer cargo colored 3.1.1 color/Color#Red# } |
| 406 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_greenrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_green().: (0, 205, 0), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green# } |
| 407 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_yellowrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_yellow().: (205, 205, 0), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow# } |
| 408 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_bluerust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_blue().: (0, 0, 238), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue# } |
| 409 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_magentarust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_magenta().: (205, 0, 205), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta# } |
| 410 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_cyanrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_cyan().: (0, 205, 205), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan# } |
| 411 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { exact_whiterust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/exact_white().: (229, 229, 229), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White# } |
| 412 | |
| 413 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_blackrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_black().: (10, 15, 10), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Blackrust-analyzer cargo colored 3.1.1 color/Color#Black# } |
| 414 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_redrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_red().: (215, 10, 10), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Redrust-analyzer cargo colored 3.1.1 color/Color#Red# } |
| 415 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_greenrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_green().: (10, 195, 10), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Greenrust-analyzer cargo colored 3.1.1 color/Color#Green# } |
| 416 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_yellowrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_yellow().: (195, 215, 10), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Yellowrust-analyzer cargo colored 3.1.1 color/Color#Yellow# } |
| 417 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_bluerust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_blue().: (0, 0, 200), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Bluerust-analyzer cargo colored 3.1.1 color/Color#Blue# } |
| 418 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_magentarust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_magenta().: (215, 0, 195), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Magentarust-analyzer cargo colored 3.1.1 color/Color#Magenta# } |
| 419 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_cyanrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_cyan().: (10, 215, 215), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Cyanrust-analyzer cargo colored 3.1.1 color/Color#Cyan# } |
| 420 | make_euclidean_distance_testrust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/make_euclidean_distance_test!! { almost_whiterust-analyzer cargo colored 3.1.1 color/tests/closest_euclidean/almost_white().: (209, 209, 229), Colorrust-analyzer cargo colored 3.1.1 color/Color#::Whiterust-analyzer cargo colored 3.1.1 color/Color#White# } |
| 421 | } |
| 422 | } |