pub(super) fn longest_consecutive_run(content: &str, marker: char) -> usize {
content
.chars()
.fold((0usize, 0usize), |(max, current), c| {
if c == marker {
let next = current + 1;
(max.max(next), next)
} else {
(max, 0)
}
})
.0
}
pub(super) fn min_safe_code_span_delimiter_length(content: &str) -> usize {
let mut run_lengths = std::collections::HashSet::new();
let mut current = 0usize;
for c in content.chars() {
if c == '`' {
current += 1;
} else {
if current > 0 {
run_lengths.insert(current);
}
current = 0;
}
}
if current > 0 {
run_lengths.insert(current);
}
let mut candidate = 1usize;
while run_lengths.contains(&candidate) {
candidate += 1;
}
candidate
}