From f3b61853904fd6205df1f1041fa30d6eb6200af8 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 2 May 2024 13:54:54 -0700 Subject: [PATCH] fix terminated --- crates/toml_edit/src/parser/strings.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/toml_edit/src/parser/strings.rs b/crates/toml_edit/src/parser/strings.rs index f1bf46e4..9705aa24 100644 --- a/crates/toml_edit/src/parser/strings.rs +++ b/crates/toml_edit/src/parser/strings.rs @@ -218,7 +218,8 @@ fn mlb_quotes<'i>( move |input: &mut Input<'i>| { let start = input.checkpoint(); let res = terminated(b"\"\"", peek(term.by_ref())) - // Safety: ??? + // Safety: terminated returns the output of the first parser here, + // which only parses ASCII .map(|b| unsafe { from_utf8_unchecked(b, "`bytes` out non-ASCII") }) .parse_next(input); @@ -226,7 +227,8 @@ fn mlb_quotes<'i>( Err(winnow::error::ErrMode::Backtrack(_)) => { input.reset(&start); terminated(b"\"", peek(term.by_ref())) - // Safety: ??? + // Safety: terminated returns the output of the first parser here, + // which only parses ASCII .map(|b| unsafe { from_utf8_unchecked(b, "`bytes` out non-ASCII") }) .parse_next(input) } @@ -349,7 +351,8 @@ fn mll_quotes<'i>( move |input: &mut Input<'i>| { let start = input.checkpoint(); let res = terminated(b"''", peek(term.by_ref())) - // Safety: ??? + // Safety: terminated returns the output of the first parser here, + // which only parses ASCII .map(|b| unsafe { from_utf8_unchecked(b, "`bytes` out non-ASCII") }) .parse_next(input); @@ -357,7 +360,8 @@ fn mll_quotes<'i>( Err(winnow::error::ErrMode::Backtrack(_)) => { input.reset(&start); terminated(b"'", peek(term.by_ref())) - // Safety: ??? + // Safety: terminated returns the output of the first parser here, + // which only parses ASCII .map(|b| unsafe { from_utf8_unchecked(b, "`bytes` out non-ASCII") }) .parse_next(input) }