1
Fork 0
mirror of https://github.com/RGBCube/cstree synced 2025-07-27 09:07:44 +00:00

use fold_chunks in for_each_chunk

This commit is contained in:
Domenic Quirl 2022-02-20 09:41:43 +01:00
parent 2b084c6f82
commit f88b980ed1

View file

@ -199,17 +199,10 @@ impl<'n, 'i, I: Resolver + ?Sized, L: Language, D> SyntaxText<'n, 'i, I, L, D> {
/// Applies the given function to all text chunks that this text is comprised of, in order.
///
/// See also [`try_fold_chunks`](SyntaxText::try_fold_chunks),
/// See also [`fold_chunks`](SyntaxText::fold_chunks),
/// [`try_for_each_chunk`](SyntaxText::try_for_each_chunk).
pub fn for_each_chunk<F: FnMut(&str)>(&self, mut f: F) {
enum Void {}
match self.try_for_each_chunk(|chunk| {
f(chunk);
Ok::<(), Void>(())
}) {
Ok(()) => (),
Err(void) => match void {},
}
self.fold_chunks((), |(), chunk| f(chunk))
}
fn tokens_with_ranges(&self) -> impl Iterator<Item = (&SyntaxToken<L, D>, TextRange)> {