1use alloc::string::String;
10
11use crate::props::{
12 basic::color::{parse_css_color, ColorU, CssColorParseError, CssColorParseErrorOwned},
13 formatter::PrintAsCssValue,
14};
15
16const DEFAULT_SELECTION_BG: ColorU = ColorU::new(173, 214, 255, 255);
18
19#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
23#[repr(C)]
24pub struct SelectionBackgroundColor {
25 pub inner: ColorU,
26}
27
28impl Default for SelectionBackgroundColor {
29 fn default() -> Self {
30 Self {
31 inner: DEFAULT_SELECTION_BG,
32 }
33 }
34}
35
36impl PrintAsCssValue for SelectionBackgroundColor {
37 fn print_as_css_value(&self) -> String {
38 self.inner.to_hash()
39 }
40}
41
42impl crate::codegen::format::FormatAsRustCode for SelectionBackgroundColor {
43 fn format_as_rust_code(&self, _tabs: usize) -> String {
44 format!(
45 "SelectionBackgroundColor {{ inner: {} }}",
46 crate::codegen::format::format_color_value(&self.inner)
47 )
48 }
49}
50
51#[cfg(feature = "parser")]
53pub fn parse_selection_background_color(
57 input: &str,
58) -> Result<SelectionBackgroundColor, CssColorParseError<'_>> {
59 parse_css_color(input).map(|inner| SelectionBackgroundColor { inner })
60}
61
62#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
66#[repr(C)]
67pub struct SelectionColor {
68 pub inner: ColorU,
69}
70
71impl Default for SelectionColor {
72 fn default() -> Self {
73 Self {
74 inner: ColorU::BLACK,
75 }
76 }
77}
78
79impl PrintAsCssValue for SelectionColor {
80 fn print_as_css_value(&self) -> String {
81 self.inner.to_hash()
82 }
83}
84
85impl crate::codegen::format::FormatAsRustCode for SelectionColor {
86 fn format_as_rust_code(&self, _tabs: usize) -> String {
87 format!(
88 "SelectionColor {{ inner: {} }}",
89 crate::codegen::format::format_color_value(&self.inner)
90 )
91 }
92}
93
94#[cfg(feature = "parser")]
96pub fn parse_selection_color(input: &str) -> Result<SelectionColor, CssColorParseError<'_>> {
100 parse_css_color(input).map(|inner| SelectionColor { inner })
101}
102
103use crate::props::basic::{
106 pixel::{parse_pixel_value, CssPixelValueParseError, CssPixelValueParseErrorOwned, PixelValue},
107 SizeMetric,
108};
109
110#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
112#[repr(C)]
113pub struct SelectionRadius {
114 pub inner: PixelValue,
115}
116
117impl Default for SelectionRadius {
118 fn default() -> Self {
119 Self {
120 inner: PixelValue::zero(),
121 }
122 }
123}
124
125impl PrintAsCssValue for SelectionRadius {
126 fn print_as_css_value(&self) -> String {
127 self.inner.to_string()
128 }
129}
130
131impl crate::codegen::format::FormatAsRustCode for SelectionRadius {
132 fn format_as_rust_code(&self, _tabs: usize) -> String {
133 format!(
135 "SelectionRadius {{ inner: PixelValue::from_metric(SizeMetric::{:?}, {}) }}",
136 self.inner.metric,
137 self.inner.number.get()
138 )
139 }
140}
141
142#[cfg(feature = "parser")]
144pub fn parse_selection_radius(input: &str) -> Result<SelectionRadius, CssPixelValueParseError<'_>> {
148 parse_pixel_value(input).map(|inner| SelectionRadius { inner })
149}
150
151#[cfg(all(test, feature = "parser"))]
152mod autotest_generated {
153 use std::{
154 collections::hash_map::DefaultHasher,
155 hash::{Hash, Hasher},
156 };
157
158 use super::*;
159 use crate::codegen::format::FormatAsRustCode;
160
161 fn hash_of<T: Hash>(t: &T) -> u64 {
162 let mut h = DefaultHasher::new();
163 t.hash(&mut h);
164 h.finish()
165 }
166
167 const ROUND_TRIPPABLE_METRICS: [SizeMetric; 11] = [
172 SizeMetric::Px,
173 SizeMetric::Pt,
174 SizeMetric::Em,
175 SizeMetric::Rem,
176 SizeMetric::In,
177 SizeMetric::Cm,
178 SizeMetric::Mm,
179 SizeMetric::Percent,
180 SizeMetric::Vw,
181 SizeMetric::Vh,
182 SizeMetric::Vmax,
183 ];
184
185 fn hostile_corpus() -> Vec<String> {
188 vec![
189 String::new(),
190 " ".to_string(),
191 "\t\n\r\u{b}\u{c}".to_string(),
192 "\u{a0}".to_string(), "\u{200b}".to_string(), "\0".to_string(),
195 "#\0\0\0".to_string(),
196 ";".to_string(),
197 "}{".to_string(),
198 ")rgb(".to_string(),
199 "#".to_string(),
200 "##".to_string(),
201 "#zzz".to_string(),
202 "#-fff000f".to_string(), "rgb(".to_string(),
204 "rgb()".to_string(),
205 "rgb(1,2)".to_string(),
206 "rgb(-1,-1,-1)".to_string(),
207 "rgb(999,999,999)".to_string(),
208 "rgba(0,0,0,NaN)".to_string(),
209 "rgba(255,255,255,inf)".to_string(),
210 "hsl(400,-10%,999%)".to_string(),
211 "-".to_string(),
212 "--".to_string(),
213 "+".to_string(),
214 "e".to_string(),
215 "E9".to_string(),
216 "NaN".to_string(),
217 "inf".to_string(),
218 "-inf".to_string(),
219 "infinity".to_string(),
220 "0x10px".to_string(),
221 "px".to_string(),
222 "vmin".to_string(),
223 "5 5px".to_string(),
224 "5px;".to_string(),
225 "%".to_string(),
226 "-0".to_string(),
227 i64::MAX.to_string(),
228 i64::MIN.to_string(),
229 format!("{}px", i64::MAX),
230 "1e400px".to_string(),
231 "\u{1F600}".to_string(),
232 "#\u{1F600}".to_string(), "#\u{e9}1".to_string(), "a\u{0301}\u{0301}\u{0301}".to_string(), "\u{202e}der".to_string(), "\u{130}".to_string(), "RED".to_string(),
238 "red red".to_string(),
239 ]
240 }
241
242 #[test]
243 fn hostile_inputs_never_panic_in_any_selection_parser() {
244 for input in hostile_corpus() {
245 let _ = parse_selection_background_color(&input);
246 let _ = parse_selection_color(&input);
247
248 if let Ok(r) = parse_selection_radius(&input) {
253 assert!(
254 r.inner.number.get().is_finite(),
255 "{input:?} produced a non-finite radius"
256 );
257 }
258 }
259 }
260
261 #[test]
264 fn empty_and_whitespace_only_input_is_rejected() {
265 for blank in ["", " ", " ", "\t\n", "\r\n\t ", "\u{a0}", "\u{2003}"] {
267 assert!(
268 matches!(
269 parse_selection_background_color(blank),
270 Err(CssColorParseError::EmptyInput)
271 ),
272 "{blank:?} should be EmptyInput"
273 );
274 assert!(
275 matches!(
276 parse_selection_color(blank),
277 Err(CssColorParseError::EmptyInput)
278 ),
279 "{blank:?} should be EmptyInput"
280 );
281 assert!(
282 matches!(
283 parse_selection_radius(blank),
284 Err(CssPixelValueParseError::EmptyString)
285 ),
286 "{blank:?} should be EmptyString"
287 );
288 }
289
290 assert!(parse_selection_color("\u{200b}").is_err());
293 assert!(parse_selection_radius("\u{200b}").is_err());
294 }
295
296 #[test]
299 fn malformed_color_input_is_rejected_without_panicking() {
300 for bad in [
301 "#", "##", "#f", "#ff", "#fffff", "#zzz", "#gggggg", "rgb(", "rgb()", "rgb(1,2)",
302 "rgb(1,2,3", "rgba(1,2,3)", "hsl(1,2)", "not-a-color", "}{", ";", ")rgb(",
303 "rgb (0,0,0)", ] {
305 assert!(
306 parse_selection_background_color(bad).is_err(),
307 "{bad:?} was accepted as a background color"
308 );
309 assert!(
310 parse_selection_color(bad).is_err(),
311 "{bad:?} was accepted as a color"
312 );
313 }
314 }
315
316 #[test]
317 fn malformed_radius_input_is_rejected_without_panicking() {
318 for bad in [
319 "px", "em", "%", "5 5px", "5px;", "px5", "5pxpx", "--5px", "5,px", "#5px", "5 px x",
320 "0x10px", "e", "+",
321 ] {
322 assert!(
323 parse_selection_radius(bad).is_err(),
324 "{bad:?} was accepted as a radius"
325 );
326 }
327
328 assert!(matches!(
330 parse_selection_radius("px"),
331 Err(CssPixelValueParseError::NoValueGiven("px", SizeMetric::Px))
332 ));
333 }
334
335 #[test]
338 fn surrounding_whitespace_is_trimmed_but_trailing_junk_is_rejected() {
339 assert_eq!(
341 parse_selection_background_color(" #ff0000ff ").unwrap().inner,
342 ColorU::new(255, 0, 0, 255)
343 );
344 assert_eq!(
345 parse_selection_color("\t red \n").unwrap().inner,
346 ColorU::new(255, 0, 0, 255)
347 );
348 assert_eq!(
349 parse_selection_radius(" 5px \n").unwrap().inner,
350 PixelValue::px(5.0)
351 );
352 assert_eq!(
354 parse_selection_radius("5 px").unwrap().inner,
355 PixelValue::px(5.0)
356 );
357
358 for junk in ["#ff0000;", "red;", "red garbage", "#ff0000ff extra"] {
360 assert!(
361 parse_selection_color(junk).is_err(),
362 "{junk:?} was silently truncated to a valid color"
363 );
364 }
365 for junk in ["5px;", "5px garbage", "5px 6px"] {
366 assert!(
367 parse_selection_radius(junk).is_err(),
368 "{junk:?} was silently truncated to a valid radius"
369 );
370 }
371 }
372
373 #[test]
376 fn extremely_long_input_neither_panics_nor_hangs() {
377 let long_hex = format!("#{}", "f".repeat(1_000_000));
378 assert!(parse_selection_background_color(&long_hex).is_err());
379 assert!(parse_selection_color(&long_hex).is_err());
380
381 let long_word = "z".repeat(1_000_000);
382 assert!(parse_selection_color(&long_word).is_err());
383 assert!(parse_selection_radius(&long_word).is_err());
384
385 let long_number = format!("{}px", "9".repeat(1_000_000));
388 let r = parse_selection_radius(&long_number).unwrap();
389 assert!(r.inner.number.get().is_finite());
390 assert_eq!(r.inner, PixelValue::px(f32::INFINITY));
391 }
392
393 #[test]
394 fn deeply_nested_input_does_not_stack_overflow() {
395 let open = "(".repeat(10_000);
396 assert!(parse_selection_color(&open).is_err());
397 assert!(parse_selection_radius(&open).is_err());
398
399 let unclosed = "rgb(".repeat(10_000);
400 assert!(parse_selection_background_color(&unclosed).is_err());
401
402 let balanced = format!("{}{}", "rgb(".repeat(10_000), ")".repeat(10_000));
403 assert!(parse_selection_background_color(&balanced).is_err());
404 }
405
406 #[test]
409 fn unicode_input_is_rejected_without_slicing_through_a_char() {
410 for u in [
414 "#\u{e9}1", "#\u{1F600}", "#\u{e9}\u{e9}\u{e9}", "\u{1F600}",
418 "a\u{0301}\u{0301}",
419 "\u{202e}red",
420 "\u{130}", "r\u{e9}d",
422 ] {
423 assert!(
424 parse_selection_background_color(u).is_err(),
425 "{u:?} was accepted as a color"
426 );
427 assert!(parse_selection_color(u).is_err(), "{u:?} was accepted");
428 assert!(parse_selection_radius(u).is_err(), "{u:?} was accepted");
429 }
430 }
431
432 #[test]
435 fn radius_nan_and_infinity_saturate_instead_of_leaking_into_layout() {
436 let nan = parse_selection_radius("NaN").unwrap();
441 assert_eq!(nan.inner.number.get(), 0.0, "NaN must collapse to 0");
442 assert!(nan.inner.number.get().is_finite());
443
444 let pos_inf = parse_selection_radius("inf").unwrap();
445 assert!(pos_inf.inner.number.get().is_finite());
446 assert!(pos_inf.inner.number.get() > 0.0);
447
448 let neg_inf = parse_selection_radius("-inf").unwrap();
449 assert!(neg_inf.inner.number.get().is_finite());
450 assert!(neg_inf.inner.number.get() < 0.0);
451
452 assert_eq!(pos_inf.inner, PixelValue::px(f32::INFINITY));
454 assert_eq!(
455 parse_selection_radius("1e40px").unwrap().inner,
456 PixelValue::px(f32::INFINITY)
457 );
458 assert_eq!(
459 parse_selection_radius(&format!("{}px", i64::MAX))
460 .unwrap()
461 .inner,
462 PixelValue::px(f32::INFINITY)
463 );
464 assert_eq!(
465 parse_selection_radius(&format!("{}px", i64::MIN))
466 .unwrap()
467 .inner,
468 PixelValue::px(f32::NEG_INFINITY)
469 );
470 }
471
472 #[test]
473 fn radius_zero_boundaries_are_normalized() {
474 assert_eq!(parse_selection_radius("0px").unwrap().inner, PixelValue::px(0.0));
475 assert_eq!(
477 parse_selection_radius("-0px").unwrap().inner,
478 parse_selection_radius("0px").unwrap().inner
479 );
480 assert_eq!(
481 parse_selection_radius("-0.0px").unwrap().inner,
482 PixelValue::zero()
483 );
484
485 assert_eq!(
487 parse_selection_radius("1e-45px").unwrap().inner.number.get(),
488 0.0
489 );
490 assert_eq!(
491 parse_selection_radius("0.0001px").unwrap().inner.number.get(),
492 0.0
493 );
494 assert_eq!(
496 parse_selection_radius("0.001px").unwrap().inner.number.get(),
497 0.001
498 );
499 }
500
501 #[test]
502 fn radius_accepts_unitless_numbers_which_css_would_reject() {
503 assert_eq!(parse_selection_radius("12").unwrap().inner, PixelValue::px(12.0));
507 assert_eq!(parse_selection_radius("-7.5").unwrap().inner, PixelValue::px(-7.5));
508 assert_eq!(parse_selection_radius("1e3").unwrap().inner, PixelValue::px(1000.0));
509 }
510
511 #[test]
512 fn color_component_boundaries_are_enforced() {
513 assert_eq!(
514 parse_selection_color("rgb(0,0,0)").unwrap().inner,
515 ColorU::new(0, 0, 0, 255)
516 );
517 assert_eq!(
518 parse_selection_color("rgb(255,255,255)").unwrap().inner,
519 ColorU::new(255, 255, 255, 255)
520 );
521 for bad in [
523 "rgb(256,0,0)",
524 "rgb(-1,0,0)",
525 "rgb(999999999999999999999,0,0)",
526 "rgba(0,0,0,2.5)",
527 "rgba(0,0,0,-1)",
528 ] {
529 assert!(
530 parse_selection_background_color(bad).is_err(),
531 "{bad:?} was accepted — a component wrapped instead of erroring"
532 );
533 }
534 }
535
536 #[test]
539 fn background_color_round_trips_through_print_as_css_value() {
540 for c in [
541 ColorU::new(0, 0, 0, 0),
542 ColorU::new(255, 255, 255, 255),
543 ColorU::new(0, 0, 0, 255),
544 ColorU::new(173, 214, 255, 255),
545 ColorU::new(1, 2, 3, 4),
546 ColorU::new(254, 253, 252, 251),
547 ColorU::new(255, 0, 128, 1),
548 SelectionBackgroundColor::default().inner,
549 ] {
550 let v = SelectionBackgroundColor { inner: c };
551 let printed = v.print_as_css_value();
552 let reparsed = parse_selection_background_color(&printed)
553 .unwrap_or_else(|e| panic!("{printed:?} did not re-parse: {e:?}"));
554 assert_eq!(reparsed, v, "round-trip changed the value via {printed:?}");
555 assert_eq!(reparsed.print_as_css_value(), printed);
557 }
558 }
559
560 #[test]
561 fn selection_color_round_trips_through_print_as_css_value() {
562 for c in [
563 ColorU::new(0, 0, 0, 0),
564 ColorU::new(255, 255, 255, 255),
565 ColorU::new(18, 52, 86, 120),
566 ColorU::new(255, 0, 0, 255),
567 SelectionColor::default().inner,
568 ] {
569 let v = SelectionColor { inner: c };
570 let printed = v.print_as_css_value();
571 let reparsed = parse_selection_color(&printed)
572 .unwrap_or_else(|e| panic!("{printed:?} did not re-parse: {e:?}"));
573 assert_eq!(reparsed, v);
574 assert_eq!(reparsed.print_as_css_value(), printed);
575 }
576 }
577
578 #[test]
579 fn every_byte_of_the_color_channels_survives_the_round_trip() {
580 for b in 0u8..=255 {
583 let c = ColorU::new(b, 255 - b, b.wrapping_mul(3), 255 - b / 2);
584 let v = SelectionColor { inner: c };
585 assert_eq!(
586 parse_selection_color(&v.print_as_css_value()).unwrap(),
587 v,
588 "channel round-trip failed for {c:?}"
589 );
590 }
591 }
592
593 #[test]
594 fn radius_round_trips_for_every_metric_except_vmin() {
595 for metric in ROUND_TRIPPABLE_METRICS {
596 for value in [0.0_f32, 1.0, 1.5, 12.0, -3.25, 0.001, -0.5, 999.999] {
597 let v = SelectionRadius {
598 inner: PixelValue::from_metric(metric, value),
599 };
600 let printed = v.print_as_css_value();
601 let reparsed = parse_selection_radius(&printed)
602 .unwrap_or_else(|e| panic!("{printed:?} did not re-parse: {e:?}"));
603 assert_eq!(
604 reparsed, v,
605 "round-trip changed {value} {metric:?} via {printed:?}"
606 );
607 assert_eq!(reparsed.inner.metric, metric);
608 assert_eq!(reparsed.print_as_css_value(), printed);
609 }
610 }
611 }
612
613 #[test]
623 fn known_bug_vmin_radius_is_rejected_by_metric_table_order() {
624 assert_eq!(
627 parse_selection_radius("5vmin").unwrap().inner.metric,
628 SizeMetric::Vmin
629 );
630
631 let v = SelectionRadius {
633 inner: PixelValue::from_metric(SizeMetric::Vmin, 5.0),
634 };
635 assert_eq!(v.print_as_css_value(), "5vmin");
636 assert_eq!(
637 parse_selection_radius(&v.print_as_css_value()).unwrap().inner.metric,
638 SizeMetric::Vmin
639 );
640
641 assert_eq!(
644 parse_selection_radius("5vmax").unwrap().inner.metric,
645 SizeMetric::Vmax
646 );
647 assert_eq!(
648 parse_selection_radius("5vw").unwrap().inner.metric,
649 SizeMetric::Vw
650 );
651 assert_eq!(
652 parse_selection_radius("5vh").unwrap().inner.metric,
653 SizeMetric::Vh
654 );
655 assert_eq!(
656 parse_selection_radius("5in").unwrap().inner.metric,
657 SizeMetric::In
658 );
659 }
660
661 #[test]
669 fn hex_color_rejects_a_leading_plus_sign() {
670 assert!(parse_selection_color("#+fff000f").is_err());
675 assert!(parse_selection_background_color("#+fff00").is_err());
676
677 assert!(parse_selection_color("#-fff000f").is_err());
680 assert!(parse_selection_color("#+ff").is_err());
681 assert!(parse_selection_color("#+fff").is_err());
682 }
683
684 #[test]
687 fn defaults_are_the_documented_values_and_re_parse_to_themselves() {
688 assert_eq!(
689 SelectionBackgroundColor::default().inner,
690 ColorU::new(173, 214, 255, 255)
691 );
692 assert_eq!(SelectionBackgroundColor::default().inner, DEFAULT_SELECTION_BG);
693 assert_eq!(SelectionColor::default().inner, ColorU::BLACK);
694 assert_eq!(SelectionRadius::default().inner, PixelValue::zero());
695
696 assert_eq!(
697 SelectionBackgroundColor::default().print_as_css_value(),
698 "#add6ffff"
699 );
700 assert_eq!(SelectionColor::default().print_as_css_value(), "#000000ff");
701 assert_eq!(SelectionRadius::default().print_as_css_value(), "0px");
702
703 assert_eq!(
704 parse_selection_background_color("#add6ffff").unwrap(),
705 SelectionBackgroundColor::default()
706 );
707 assert_eq!(
708 parse_selection_color("#000000ff").unwrap(),
709 SelectionColor::default()
710 );
711 assert_eq!(
712 parse_selection_radius("0px").unwrap(),
713 SelectionRadius::default()
714 );
715 }
716
717 #[test]
718 fn equal_values_hash_and_compare_equal() {
719 let a = SelectionColor { inner: ColorU::new(1, 2, 3, 4) };
720 let b = SelectionColor { inner: ColorU::new(1, 2, 3, 4) };
721 assert_eq!(a, b);
722 assert_eq!(hash_of(&a), hash_of(&b));
723 assert_eq!(a.cmp(&b), core::cmp::Ordering::Equal);
724
725 let black = SelectionColor { inner: ColorU::new(0, 0, 0, 255) };
726 let white = SelectionColor { inner: ColorU::new(255, 255, 255, 255) };
727 assert!(black < white);
728 assert!(white > black);
729
730 assert_eq!(
732 parse_selection_radius("1.5em").unwrap(),
733 parse_selection_radius("1.5em").unwrap()
734 );
735 assert_eq!(
736 hash_of(&parse_selection_radius("1.5em").unwrap()),
737 hash_of(&parse_selection_radius("1.5em").unwrap())
738 );
739 }
740
741 #[test]
742 fn format_as_rust_code_emits_a_constructor_for_each_type() {
743 let radius = SelectionRadius {
744 inner: PixelValue::px(5.0),
745 };
746 assert_eq!(
747 radius.format_as_rust_code(0),
748 "SelectionRadius { inner: PixelValue::from_metric(SizeMetric::Px, 5) }"
749 );
750 assert_eq!(
751 SelectionRadius {
752 inner: PixelValue::from_metric(SizeMetric::Percent, 50.0),
753 }
754 .format_as_rust_code(0),
755 "SelectionRadius { inner: PixelValue::from_metric(SizeMetric::Percent, 50) }"
756 );
757 assert_eq!(
758 SelectionRadius::default().format_as_rust_code(0),
759 "SelectionRadius { inner: PixelValue::from_metric(SizeMetric::Px, 0) }"
760 );
761
762 let bg = SelectionBackgroundColor::default().format_as_rust_code(0);
765 assert!(bg.starts_with("SelectionBackgroundColor { inner: "), "{bg}");
766 assert!(bg.ends_with(" }"), "{bg}");
767 let fg = SelectionColor::default().format_as_rust_code(0);
768 assert!(fg.starts_with("SelectionColor { inner: "), "{fg}");
769 assert!(fg.ends_with(" }"), "{fg}");
770
771 assert_eq!(radius.format_as_rust_code(0), radius.format_as_rust_code(9));
773 }
774
775 #[test]
776 fn parse_errors_survive_the_owned_round_trip() {
777 let color_err = parse_selection_color("not-a-color").unwrap_err();
780 let owned: CssColorParseErrorOwned = color_err.to_contained();
781 assert_eq!(format!("{:?}", owned.to_shared()), format!("{color_err:?}"));
782
783 let px_err = parse_selection_radius("5 5px").unwrap_err();
784 let owned_px: CssPixelValueParseErrorOwned = px_err.to_contained();
785 assert_eq!(format!("{:?}", owned_px.to_shared()), format!("{px_err:?}"));
786
787 assert!(!format!("{color_err:?}").is_empty());
789 assert!(!format!("{px_err:?}").is_empty());
790 }
791
792 #[test]
793 fn the_two_color_properties_agree_on_every_input() {
794 for input in hostile_corpus() {
797 let bg = parse_selection_background_color(&input);
798 let fg = parse_selection_color(&input);
799 match (bg, fg) {
800 (Ok(b), Ok(f)) => assert_eq!(b.inner, f.inner, "diverged on {input:?}"),
801 (Err(_), Err(_)) => {}
802 (b, f) => panic!("{input:?} parsed inconsistently: {b:?} vs {f:?}"),
803 }
804 }
805 }
806}