Skip to content

Commit

Permalink
docs: extra doc comments in str_till_eol
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Dec 17, 2024
1 parent c02d7d5 commit 352540f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions console/network/environment/src/helpers/sanitizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ impl Sanitizer {
///
/// Discard any leading newline.
fn str_till_eol(string: &str) -> ParserResult<&str> {
// A heuristic approach is applied here in order to avoid
// costly parsing operations in the most common scenarios.
// A heuristic approach is applied here in order to avoid costly parsing operations in the
// most common scenarios: non-parsing methods are used to verify if the string has multiple
// lines and if there are any unsafe characters.
if let Some((before, after)) = string.split_once('\n') {
let is_multiline = before.ends_with('\\');

Expand All @@ -128,6 +129,8 @@ impl Sanitizer {
if !contains_unsafe_chars {
Ok((after, before))
} else {
// `eoi` is used here instead of `eol`, since the earlier call to `split_once`
// already removed the newline
recognize(Self::till(value((), Sanitizer::parse_safe_char), Self::eoi))(before)
}
} else {
Expand Down

0 comments on commit 352540f

Please sign in to comment.