Skip to content

Commit

Permalink
run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kartva committed Nov 19, 2022
1 parent a3f8fd7 commit 6d4b2b4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/ide-db/src/syntax_helpers/format_string_exprs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
output.push(chr);
extracted_expressions.push(Arg::Placeholder);
state = State::NotArg;
},
}
(State::MaybeArg, ':') => {
output.push(chr);
extracted_expressions.push(Arg::Placeholder);
state = State::FormatOpts;
},
}
(State::MaybeArg, _) => {
if matches!(chr, '\\' | '$') {
current_expr.push('\\');
Expand All @@ -122,13 +122,13 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
} else {
state = State::Expr;
}
},
}
(State::Ident | State::Expr, ':') if matches!(chars.peek(), Some(':')) => {
// path separator
state = State::Expr;
current_expr.push_str("::");
chars.next();
},
}
(State::Ident | State::Expr, ':' | '}') => {
if inexpr_open_count == 0 {
let trimmed = current_expr.trim();
Expand All @@ -146,7 +146,13 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {

output.push(chr);
current_expr.clear();
state = if chr == ':' {State::FormatOpts} else if chr == '}' {State::NotArg} else {unreachable!()};
state = if chr == ':' {
State::FormatOpts
} else if chr == '}' {
State::NotArg
} else {
unreachable!()
};
} else if chr == '}' {
// We're closing one brace met before inside of the expression.
current_expr.push(chr);
Expand All @@ -155,7 +161,7 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
// We're inside of braced expression, assume that it's a struct field name/value delimiter.
current_expr.push(chr);
}
},
}
(State::Ident | State::Expr, '{') => {
state = State::Expr;
current_expr.push(chr);
Expand Down

0 comments on commit 6d4b2b4

Please sign in to comment.