(args: &[String], cwd: &Path)
| 763 | } |
| 764 | |
| 765 | out |
| 766 | } |
| 767 | |
| 768 | fn format_key_value_line(line: &str) -> String { |
| 769 | let Some(eq_idx) = find_equals_outside_strings(line) else { |
| 770 | return line.to_string(); |
| 771 | }; |
| 772 | let (left, right) = line.split_at(eq_idx); |
| 773 | format!("{} = {}", left.trim(), right[1..].trim()) |
| 774 | } |
| 775 | |
| 776 | fn find_equals_outside_strings(line: &str) -> Option<usize> { |
| 777 | let mut escaped = false; |
| 778 | let mut in_string = false; |
| 779 | for (idx, ch) in line.char_indices() { |
| 780 | if escaped { |
| 781 | escaped = false; |
| 782 | continue; |
| 783 | } |
| 784 | match ch { |
| 785 | '\\' if in_string => escaped = true, |
| 786 | '"' => in_string = !in_string, |
| 787 | '=' if !in_string => return Some(idx), |
| 788 | _ => {} |
| 789 | } |
| 790 | } |
| 791 | None |
| 792 | } |
| 793 | |
| 794 | fn leading_close_braces(line: &str) -> usize { |
| 795 | line.chars().take_while(|ch| *ch == '}').count() |
no test coverage detected