mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-28 06:14:56 +00:00
Use selected for better readibility
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
This commit is contained in:
parent
11d7413482
commit
64723e1675
1 changed files with 5 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue