Skip to content

Commit 3ccb117

Browse files
committed
fixed fmt
1 parent 8e8e839 commit 3ccb117

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

parser/src/fstring.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'a> FStringParser<'a> {
2727
let mut delims = Vec::new();
2828
let mut conversion = None;
2929
let mut pred_expression_text = String::new();
30-
let mut trailing_seq=String::new();
30+
let mut trailing_seq = String::new();
3131

3232
while let Some(ch) = self.chars.next() {
3333
match ch {
@@ -77,7 +77,8 @@ impl<'a> FStringParser<'a> {
7777

7878
// match a python 3.8 self documenting expression
7979
// format '{' PYTHON_EXPRESSION '=' FORMAT_SPECIFIER? '}'
80-
'=' if self.chars.peek() != Some(&'=') => { // check for delims empty?
80+
'=' if self.chars.peek() != Some(&'=') => {
81+
// check for delims empty?
8182
pred_expression_text = expression.to_string(); // safe expression before = to print it
8283
}
8384

@@ -161,28 +162,25 @@ impl<'a> FStringParser<'a> {
161162
conversion,
162163
spec,
163164
});
164-
}
165-
else {
166-
return Ok(Joined{
167-
values:vec![
168-
Constant{
169-
value:pred_expression_text.to_owned()+"="
170-
},
171-
172-
Constant {
173-
value:trailing_seq.to_owned()
174-
},
175-
176-
FormattedValue {
165+
} else {
166+
return Ok(Joined {
167+
values: vec![
168+
Constant {
169+
value: pred_expression_text.to_owned() + "=",
170+
},
171+
Constant {
172+
value: trailing_seq.to_owned(),
173+
},
174+
FormattedValue {
177175
value: Box::new(
178176
parse_expression(expression.trim())
179177
.map_err(|e| InvalidExpression(Box::new(e.error)))?,
180178
),
181179
conversion,
182-
spec,},
183-
]
184-
}
185-
);
180+
spec,
181+
},
182+
],
183+
});
186184
}
187185
}
188186
'"' | '\'' => {
@@ -360,24 +358,24 @@ mod tests {
360358

361359
#[test]
362360
fn test_fstring_parse_selfdocumenting_base() {
363-
let src=String::from("{user=}");
364-
let parse_ast=parse_fstring(&src);
361+
let src = String::from("{user=}");
362+
let parse_ast = parse_fstring(&src);
365363

366364
assert!(parse_ast.is_ok());
367365
}
368366

369367
#[test]
370368
fn test_fstring_parse_selfdocumenting_base_more() {
371-
let src=String::from("mix {user=} with text and {second=}");
372-
let parse_ast=parse_fstring(&src);
369+
let src = String::from("mix {user=} with text and {second=}");
370+
let parse_ast = parse_fstring(&src);
373371

374372
assert!(parse_ast.is_ok());
375373
}
376374

377375
#[test]
378376
fn test_fstring_parse_selfdocumenting_format() {
379-
let src=String::from("{user=:>10}");
380-
let parse_ast=parse_fstring(&src);
377+
let src = String::from("{user=:>10}");
378+
let parse_ast = parse_fstring(&src);
381379

382380
assert!(parse_ast.is_ok());
383381
}

0 commit comments

Comments
 (0)