| 1 |
Description: Relax phf dependency version to 0.11 |
| 2 |
Author: Nadzeya Hutsko <[email protected]> |
| 3 |
Forwarded: not-needed |
| 4 |
Last-Update: 2025-12-03 |
| 5 |
--- |
| 6 |
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ |
| 7 |
--- a/Cargo.toml |
| 8 |
+++ b/Cargo.toml |
| 9 |
@@ -122,7 +122,7 @@ features = ["libm"] |
| 10 |
default-features = false |
| 11 |
|
| 12 |
[dependencies.phf] |
| 13 |
|
| 14 |
+version = "0.11" |
| 15 |
features = [ |
| 16 |
"macros", |
| 17 |
"uncased", |
| 18 |
--- a/src/named_colors.rs |
| 19 |
+++ b/src/named_colors.rs |
| 20 |
@@ -1,153 +1,151 @@ |
| 21 |
|
| 22 |
|
| 23 |
/// Named colors defined in <https://www.w3.org/TR/css-color-4/#named-colors>. |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
+pub static NAMED_COLORS: phf::OrderedMap<&'static str, [u8; 3]> = phf::phf_ordered_map! { |
| 174 |
+ "aliceblue" => [240, 248, 255], |
| 175 |
+ "antiquewhite" => [250, 235, 215], |
| 176 |
+ "aqua" => [0, 255, 255], |
| 177 |
+ "aquamarine" => [127, 255, 212], |
| 178 |
+ "azure" => [240, 255, 255], |
| 179 |
+ "beige" => [245, 245, 220], |
| 180 |
+ "bisque" => [255, 228, 196], |
| 181 |
+ "black" => [0, 0, 0], |
| 182 |
+ "blanchedalmond" => [255, 235, 205], |
| 183 |
+ "blue" => [0, 0, 255], |
| 184 |
+ "blueviolet" => [138, 43, 226], |
| 185 |
+ "brown" => [165, 42, 42], |
| 186 |
+ "burlywood" => [222, 184, 135], |
| 187 |
+ "cadetblue" => [95, 158, 160], |
| 188 |
+ "chartreuse" => [127, 255, 0], |
| 189 |
+ "chocolate" => [210, 105, 30], |
| 190 |
+ "coral" => [255, 127, 80], |
| 191 |
+ "cornflowerblue" => [100, 149, 237], |
| 192 |
+ "cornsilk" => [255, 248, 220], |
| 193 |
+ "crimson" => [220, 20, 60], |
| 194 |
+ "cyan" => [0, 255, 255], |
| 195 |
+ "darkblue" => [0, 0, 139], |
| 196 |
+ "darkcyan" => [0, 139, 139], |
| 197 |
+ "darkgoldenrod" => [184, 134, 11], |
| 198 |
+ "darkgray" => [169, 169, 169], |
| 199 |
+ "darkgreen" => [0, 100, 0], |
| 200 |
+ "darkgrey" => [169, 169, 169], |
| 201 |
+ "darkkhaki" => [189, 183, 107], |
| 202 |
+ "darkmagenta" => [139, 0, 139], |
| 203 |
+ "darkolivegreen" => [85, 107, 47], |
| 204 |
+ "darkorange" => [255, 140, 0], |
| 205 |
+ "darkorchid" => [153, 50, 204], |
| 206 |
+ "darkred" => [139, 0, 0], |
| 207 |
+ "darksalmon" => [233, 150, 122], |
| 208 |
+ "darkseagreen" => [143, 188, 143], |
| 209 |
+ "darkslateblue" => [72, 61, 139], |
| 210 |
+ "darkslategray" => [47, 79, 79], |
| 211 |
+ "darkslategrey" => [47, 79, 79], |
| 212 |
+ "darkturquoise" => [0, 206, 209], |
| 213 |
+ "darkviolet" => [148, 0, 211], |
| 214 |
+ "deeppink" => [255, 20, 147], |
| 215 |
+ "deepskyblue" => [0, 191, 255], |
| 216 |
+ "dimgray" => [105, 105, 105], |
| 217 |
+ "dimgrey" => [105, 105, 105], |
| 218 |
+ "dodgerblue" => [30, 144, 255], |
| 219 |
+ "firebrick" => [178, 34, 34], |
| 220 |
+ "floralwhite" => [255, 250, 240], |
| 221 |
+ "forestgreen" => [34, 139, 34], |
| 222 |
+ "fuchsia" => [255, 0, 255], |
| 223 |
+ "gainsboro" => [220, 220, 220], |
| 224 |
+ "ghostwhite" => [248, 248, 255], |
| 225 |
+ "gold" => [255, 215, 0], |
| 226 |
+ "goldenrod" => [218, 165, 32], |
| 227 |
+ "gray" => [128, 128, 128], |
| 228 |
+ "green" => [0, 128, 0], |
| 229 |
+ "greenyellow" => [173, 255, 47], |
| 230 |
+ "grey" => [128, 128, 128], |
| 231 |
+ "honeydew" => [240, 255, 240], |
| 232 |
+ "hotpink" => [255, 105, 180], |
| 233 |
+ "indianred" => [205, 92, 92], |
| 234 |
+ "indigo" => [75, 0, 130], |
| 235 |
+ "ivory" => [255, 255, 240], |
| 236 |
+ "khaki" => [240, 230, 140], |
| 237 |
+ "lavender" => [230, 230, 250], |
| 238 |
+ "lavenderblush" => [255, 240, 245], |
| 239 |
+ "lawngreen" => [124, 252, 0], |
| 240 |
+ "lemonchiffon" => [255, 250, 205], |
| 241 |
+ "lightblue" => [173, 216, 230], |
| 242 |
+ "lightcoral" => [240, 128, 128], |
| 243 |
+ "lightcyan" => [224, 255, 255], |
| 244 |
+ "lightgoldenrodyellow" => [250, 250, 210], |
| 245 |
+ "lightgray" => [211, 211, 211], |
| 246 |
+ "lightgreen" => [144, 238, 144], |
| 247 |
+ "lightgrey" => [211, 211, 211], |
| 248 |
+ "lightpink" => [255, 182, 193], |
| 249 |
+ "lightsalmon" => [255, 160, 122], |
| 250 |
+ "lightseagreen" => [32, 178, 170], |
| 251 |
+ "lightskyblue" => [135, 206, 250], |
| 252 |
+ "lightslategray" => [119, 136, 153], |
| 253 |
+ "lightslategrey" => [119, 136, 153], |
| 254 |
+ "lightsteelblue" => [176, 196, 222], |
| 255 |
+ "lightyellow" => [255, 255, 224], |
| 256 |
+ "lime" => [0, 255, 0], |
| 257 |
+ "limegreen" => [50, 205, 50], |
| 258 |
+ "linen" => [250, 240, 230], |
| 259 |
+ "magenta" => [255, 0, 255], |
| 260 |
+ "maroon" => [128, 0, 0], |
| 261 |
+ "mediumaquamarine" => [102, 205, 170], |
| 262 |
+ "mediumblue" => [0, 0, 205], |
| 263 |
+ "mediumorchid" => [186, 85, 211], |
| 264 |
+ "mediumpurple" => [147, 112, 219], |
| 265 |
+ "mediumseagreen" => [60, 179, 113], |
| 266 |
+ "mediumslateblue" => [123, 104, 238], |
| 267 |
+ "mediumspringgreen" => [0, 250, 154], |
| 268 |
+ "mediumturquoise" => [72, 209, 204], |
| 269 |
+ "mediumvioletred" => [199, 21, 133], |
| 270 |
+ "midnightblue" => [25, 25, 112], |
| 271 |
+ "mintcream" => [245, 255, 250], |
| 272 |
+ "mistyrose" => [255, 228, 225], |
| 273 |
+ "moccasin" => [255, 228, 181], |
| 274 |
+ "navajowhite" => [255, 222, 173], |
| 275 |
+ "navy" => [0, 0, 128], |
| 276 |
+ "oldlace" => [253, 245, 230], |
| 277 |
+ "olive" => [128, 128, 0], |
| 278 |
+ "olivedrab" => [107, 142, 35], |
| 279 |
+ "orange" => [255, 165, 0], |
| 280 |
+ "orangered" => [255, 69, 0], |
| 281 |
+ "orchid" => [218, 112, 214], |
| 282 |
+ "palegoldenrod" => [238, 232, 170], |
| 283 |
+ "palegreen" => [152, 251, 152], |
| 284 |
+ "paleturquoise" => [175, 238, 238], |
| 285 |
+ "palevioletred" => [219, 112, 147], |
| 286 |
+ "papayawhip" => [255, 239, 213], |
| 287 |
+ "peachpuff" => [255, 218, 185], |
| 288 |
+ "peru" => [205, 133, 63], |
| 289 |
+ "pink" => [255, 192, 203], |
| 290 |
+ "plum" => [221, 160, 221], |
| 291 |
+ "powderblue" => [176, 224, 230], |
| 292 |
+ "purple" => [128, 0, 128], |
| 293 |
+ "rebeccapurple" => [102, 51, 153], |
| 294 |
+ "red" => [255, 0, 0], |
| 295 |
+ "rosybrown" => [188, 143, 143], |
| 296 |
+ "royalblue" => [65, 105, 225], |
| 297 |
+ "saddlebrown" => [139, 69, 19], |
| 298 |
+ "salmon" => [250, 128, 114], |
| 299 |
+ "sandybrown" => [244, 164, 96], |
| 300 |
+ "seagreen" => [46, 139, 87], |
| 301 |
+ "seashell" => [255, 245, 238], |
| 302 |
+ "sienna" => [160, 82, 45], |
| 303 |
+ "silver" => [192, 192, 192], |
| 304 |
+ "skyblue" => [135, 206, 235], |
| 305 |
+ "slateblue" => [106, 90, 205], |
| 306 |
+ "slategray" => [112, 128, 144], |
| 307 |
+ "slategrey" => [112, 128, 144], |
| 308 |
+ "snow" => [255, 250, 250], |
| 309 |
+ "springgreen" => [0, 255, 127], |
| 310 |
+ "steelblue" => [70, 130, 180], |
| 311 |
+ "tan" => [210, 180, 140], |
| 312 |
+ "teal" => [0, 128, 128], |
| 313 |
+ "thistle" => [216, 191, 216], |
| 314 |
+ "tomato" => [255, 99, 71], |
| 315 |
+ "turquoise" => [64, 224, 208], |
| 316 |
+ "violet" => [238, 130, 238], |
| 317 |
+ "wheat" => [245, 222, 179], |
| 318 |
+ "white" => [255, 255, 255], |
| 319 |
+ "whitesmoke" => [245, 245, 245], |
| 320 |
+ "yellow" => [255, 255, 0], |
| 321 |
+ "yellowgreen" => [154, 205, 50], |
| 322 |
}; |
| 323 |
--- a/src/parser.rs |
| 324 |
+++ b/src/parser.rs |
| 325 |
@@ -418,7 +418,8 @@ fn parse_abs(s: &str) -> Result<Color, P |
| 326 |
// Named colors |
| 327 |
#[cfg(feature = "named-colors")] |
| 328 |
if s.len() > 2 && s.len() < 21 { |
| 329 |
|
| 330 |
+ let lower = s.to_ascii_lowercase(); |
| 331 |
+ if let Some([r, g, b]) = NAMED_COLORS.get(&lower as &str) { |
| 332 |
return Ok(Color::from_rgba8(*r, *g, *b, 255)); |
| 333 |
} |
| 334 |
} |
| 335 |
--- a/src/color.rs |
| 336 |
+++ b/src/color.rs |
| 337 |
@@ -215,7 +215,7 @@ impl Color { |
| 338 |
let rgb = &self.to_rgba8()[0..3]; |
| 339 |
for (&k, v) in NAMED_COLORS.entries() { |
| 340 |
if v == rgb { |
| 341 |
|
| 342 |
+ return Some(k); |
| 343 |
} |
| 344 |
} |
| 345 |
None |
| 346 |
--- a/tests/named_colors.rs |
| 347 |
+++ b/tests/named_colors.rs |
| 348 |
@@ -5,20 +5,20 @@ fn named_colors() { |
| 349 |
let skip_list = ["aqua", "cyan", "fuchsia", "magenta"]; |
| 350 |
|
| 351 |
for (&name, &rgb) in NAMED_COLORS.entries() { |
| 352 |
|
| 353 |
+ let c = parse(name).unwrap(); |
| 354 |
assert_eq!(c.to_rgba8()[0..3], rgb); |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
+ if skip_list.contains(&name) |
| 360 |
+ || name.contains("gray") |
| 361 |
+ || name.contains("grey") |
| 362 |
{ |
| 363 |
continue; |
| 364 |
} |
| 365 |
|
| 366 |
+ assert_eq!(c.name(), Some(name)); |
| 367 |
|
| 368 |
let [r, g, b] = rgb; |
| 369 |
let c = Color::from_rgba8(r, g, b, 255); |
| 370 |
|
| 371 |
+ assert_eq!(c.name(), Some(name)); |
| 372 |
} |
| 373 |
|
| 374 |
// Case-insensitive tests |