Enjoy rust 1.94

This commit is contained in:
2026-03-11 20:30:45 +01:00
parent 8245596d4d
commit 1e0f7c44f7

View File

@@ -1,4 +1,4 @@
use std::iter::{self, once};
use std::iter;
use crate::markdown::Style;
@@ -142,18 +142,8 @@ fn collect_until<'a, const N: usize>(
first_token: Option<&Token<'a>>,
tokens: &mut &[Token<'a>],
pattern: impl FnMut(&[Token<'a>; N]) -> bool,
) -> Span<'a>
where
// &[T; N]: TryFrom<&[T]>
for<'b> &'b [Token<'a>; N]: TryFrom<&'b [Token<'a>]>,
{
let mut windows = tokens.windows(N).map(|slice| {
<&[Token<'a>; N]>::try_from(slice)
.ok()
.expect("`windows` promises to return slices of length N")
});
let split_at = match windows.position(pattern) {
) -> Span<'a> {
let split_at = match tokens.array_windows::<N>().position(pattern) {
Some(i) => i + N,
None => tokens.len(), // consume everything
};
@@ -161,8 +151,8 @@ where
let (consume, keep) = tokens.split_at(split_at);
*tokens = keep;
once(first_token)
.flatten()
first_token
.into_iter()
.chain(consume)
.fold(Span::empty(), |span: Span<'_>, token| {
span.try_merge(&token.span).unwrap()