summaryrefslogtreecommitdiff
path: root/src/iterators/flat_pairs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/iterators/flat_pairs.rs')
-rw-r--r--src/iterators/flat_pairs.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/iterators/flat_pairs.rs b/src/iterators/flat_pairs.rs
index 411d88b..52a2074 100644
--- a/src/iterators/flat_pairs.rs
+++ b/src/iterators/flat_pairs.rs
@@ -11,6 +11,7 @@ use alloc::rc::Rc;
use alloc::vec::Vec;
use core::fmt;
+use super::line_index::LineIndex;
use super::pair::{self, Pair};
use super::queueable_token::QueueableToken;
use super::tokens::{self, Tokens};
@@ -28,6 +29,7 @@ pub struct FlatPairs<'i, R> {
input: &'i str,
start: usize,
end: usize,
+ line_index: Rc<LineIndex>,
}
/// # Safety
@@ -42,6 +44,7 @@ pub unsafe fn new<R: RuleType>(
FlatPairs {
queue,
input,
+ line_index: Rc::new(LineIndex::new(input)),
start,
end,
}
@@ -107,7 +110,14 @@ impl<'i, R: RuleType> Iterator for FlatPairs<'i, R> {
return None;
}
- let pair = unsafe { pair::new(Rc::clone(&self.queue), self.input, self.start) };
+ let pair = unsafe {
+ pair::new(
+ Rc::clone(&self.queue),
+ self.input,
+ Rc::clone(&self.line_index),
+ self.start,
+ )
+ };
self.next_start();
Some(pair)
@@ -122,7 +132,14 @@ impl<'i, R: RuleType> DoubleEndedIterator for FlatPairs<'i, R> {
self.next_start_from_end();
- let pair = unsafe { pair::new(Rc::clone(&self.queue), self.input, self.end) };
+ let pair = unsafe {
+ pair::new(
+ Rc::clone(&self.queue),
+ self.input,
+ Rc::clone(&self.line_index),
+ self.end,
+ )
+ };
Some(pair)
}
@@ -141,6 +158,7 @@ impl<'i, R: Clone> Clone for FlatPairs<'i, R> {
FlatPairs {
queue: Rc::clone(&self.queue),
input: self.input,
+ line_index: Rc::clone(&self.line_index),
start: self.start,
end: self.end,
}