From 64723e1675f2533d498c7cfe47a08c3f1baa75e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaan=20B=C3=BCy=C3=BCkerdem?= <76952012+kaanyalova@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:33:14 +0300 Subject: [PATCH] Use selected for better readibility Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com> --- format/src/format.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/format/src/format.rs b/format/src/format.rs index 237fee5..bc1bec2 100644 --- a/format/src/format.rs +++ b/format/src/format.rs @@ -869,24 +869,17 @@ impl FormatString { let mut right = String::new(); let mut split = false; + let mut selected = &mut left; let mut inside_brackets = false; while let Some(char) = chars.next() { if char == '[' { inside_brackets = true; - if split { - right.push(char); - } else { - left.push(char); - } + selected.push(char); while let Some(next_char) = chars.next() { - if split { - right.push(next_char); - } else { - left.push(next_char); - } + selected.push(next_char); if next_char == ']' { inside_brackets = false; @@ -898,10 +891,9 @@ impl FormatString { } } else if char == ':' && !split && !inside_brackets { split = true; - } else if split { - right.push(char); + selected = &mut right; } else { - left.push(char); + selected.push(char); } }