mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
parent
3399fe10a0
commit
aab509c5c1
3 changed files with 29 additions and 15 deletions
|
@ -298,17 +298,7 @@ impl<'a> Formattable for Expr<'a> {
|
|||
}
|
||||
SingleQuote(string) => {
|
||||
buf.indent(indent);
|
||||
buf.push('\'');
|
||||
for c in string.chars() {
|
||||
if c == '"' {
|
||||
buf.push_char_literal('"')
|
||||
} else {
|
||||
for escaped in c.escape_default() {
|
||||
buf.push_char_literal(escaped);
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.push('\'');
|
||||
format_sq_literal(buf, string);
|
||||
}
|
||||
&NonBase10Int {
|
||||
base,
|
||||
|
@ -438,6 +428,20 @@ impl<'a> Formattable for Expr<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn format_sq_literal(buf: &mut Buf, s: &str) {
|
||||
buf.push('\'');
|
||||
for c in s.chars() {
|
||||
if c == '"' {
|
||||
buf.push_char_literal('"')
|
||||
} else {
|
||||
for escaped in c.escape_default() {
|
||||
buf.push_char_literal(escaped);
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.push('\'');
|
||||
}
|
||||
|
||||
fn starts_with_newline(expr: &Expr) -> bool {
|
||||
use roc_parse::ast::Expr::*;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue