1
Fork 0

Fix build_format not unescaping braces properly

Co-authored-by: RanolP <public.ranolp@gmail.com>
This commit is contained in:
finalchild 2022-08-19 02:21:35 +09:00
parent b28cc097cf
commit 8ed8aac3ca

View file

@ -235,7 +235,13 @@ pub(crate) trait HasFieldMap {
// the referenced fields. Leaves `it` sitting on the closing brace of the format string, so
// the next call to `it.next()` retrieves the next character.
while let Some(c) = it.next() {
if c == '{' && *it.peek().unwrap_or(&'\0') != '{' {
if c != '{' {
continue;
}
if *it.peek().unwrap_or(&'\0') == '{' {
assert_eq!(it.next().unwrap(), '{');
continue;
}
let mut eat_argument = || -> Option<String> {
let mut result = String::new();
// Format specifiers look like:
@ -265,7 +271,6 @@ pub(crate) trait HasFieldMap {
referenced_fields.insert(referenced_field);
}
}
}
// At this point, `referenced_fields` contains a set of the unique fields that were
// referenced in the format string. Generate the corresponding "x = self.x" format