Replace custom trim_ascii_start with the standard library method

The local trim_ascii_start function in the markdown parser duplicates
<[u8]>::trim_ascii_start() from the standard library (stable since 1.80).
Remove the custom function and call the stdlib method directly.

No behaviour change.

Fixes https://github.com/rustfoundation/interop-initiative/issues/53
This commit is contained in:
thebabalola
2026-04-13 23:07:39 +01:00
parent 1e02a2b10b
commit fdfdb0837c
+2 -8
View File
@@ -252,7 +252,7 @@ fn parse_heading(buf: &[u8]) -> ParseResult<'_> {
fn parse_unordered_li(buf: &[u8]) -> Parsed<'_> {
let (txt, rest) = get_indented_section(&buf[2..]);
let ctx = Context { .. };
let stream = parse_recursive(trim_ascii_start(txt), ctx);
let stream = parse_recursive(txt.trim_ascii_start(), ctx);
(MdTree::UnorderedListItem(stream), rest)
}
@@ -261,7 +261,7 @@ fn parse_ordered_li(buf: &[u8]) -> Parsed<'_> {
let (num, pos) = ord_list_start(buf).unwrap(); // success tested in caller
let (txt, rest) = get_indented_section(&buf[pos..]);
let ctx = Context { .. };
let stream = parse_recursive(trim_ascii_start(txt), ctx);
let stream = parse_recursive(txt.trim_ascii_start(), ctx);
(MdTree::OrderedListItem(num, stream), rest)
}
@@ -578,12 +578,6 @@ fn trim_extra_ws(mut txt: &str) -> &str {
&txt[..txt.len() - end_ws]
}
/// If there is more than one whitespace char at start, trim the extras
fn trim_ascii_start(buf: &[u8]) -> &[u8] {
let count = buf.iter().take_while(|ch| ch.is_ascii_whitespace()).count();
&buf[count..]
}
#[cfg(test)]
#[path = "tests/parse.rs"]
mod tests;