mirror of
https://github.com/RGBCube/cstree
synced 2025-07-27 17:17:45 +00:00
use fold_chunks
in for_each_chunk
This commit is contained in:
parent
2b084c6f82
commit
f88b980ed1
1 changed files with 2 additions and 9 deletions
|
@ -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.
|
/// 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).
|
/// [`try_for_each_chunk`](SyntaxText::try_for_each_chunk).
|
||||||
pub fn for_each_chunk<F: FnMut(&str)>(&self, mut f: F) {
|
pub fn for_each_chunk<F: FnMut(&str)>(&self, mut f: F) {
|
||||||
enum Void {}
|
self.fold_chunks((), |(), chunk| f(chunk))
|
||||||
match self.try_for_each_chunk(|chunk| {
|
|
||||||
f(chunk);
|
|
||||||
Ok::<(), Void>(())
|
|
||||||
}) {
|
|
||||||
Ok(()) => (),
|
|
||||||
Err(void) => match void {},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tokens_with_ranges(&self) -> impl Iterator<Item = (&SyntaxToken<L, D>, TextRange)> {
|
fn tokens_with_ranges(&self) -> impl Iterator<Item = (&SyntaxToken<L, D>, TextRange)> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue