Skip to content

Commit

Permalink
fix panic in unicode strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian8j2 committed Sep 8, 2023
1 parent b744e65 commit ead1654
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions strum_macros/src/macros/strings/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ fn capture_format_string_idents(string_literal: &LitStr) -> syn::Result<Vec<Iden
let mut new_var_start_index: Option<usize> = None;
let mut var_used: Vec<Ident> = Vec::new();

for (i, chr) in format_str.chars().enumerate() {
if chr == '{' {
for (i, chr) in format_str.bytes().enumerate() {
if chr == b'{' {
if new_var_start_index.is_some() {
return Err(syn::Error::new_spanned(
string_literal,
Expand All @@ -120,7 +120,7 @@ fn capture_format_string_idents(string_literal: &LitStr) -> syn::Result<Vec<Iden
continue;
}

if chr == '}' {
if chr == b'}' {
let start_index = new_var_start_index.take().ok_or(syn::Error::new_spanned(
string_literal,
"Bracket closed without previous opened bracket",
Expand Down

0 comments on commit ead1654

Please sign in to comment.