Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/token_map.rs')
-rw-r--r--crates/mbe/src/token_map.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/crates/mbe/src/token_map.rs b/crates/mbe/src/token_map.rs
index c2ec30ca72..5871c0f125 100644
--- a/crates/mbe/src/token_map.rs
+++ b/crates/mbe/src/token_map.rs
@@ -17,16 +17,16 @@ pub struct TokenMap<S: Span> {
}
impl<S: Span> TokenMap<S> {
- pub(crate) fn empty() -> Self {
+ pub fn empty() -> Self {
Self { spans: Vec::new() }
}
- pub(crate) fn finish(&mut self) {
+ pub fn finish(&mut self) {
assert!(self.spans.iter().tuple_windows().all(|(a, b)| a.0 < b.0));
self.spans.shrink_to_fit();
}
- pub(crate) fn push(&mut self, offset: TextSize, span: S) {
+ pub fn push(&mut self, offset: TextSize, span: S) {
self.spans.push((offset, span));
}
@@ -54,4 +54,8 @@ impl<S: Span> TokenMap<S> {
let end_entry = self.spans[start_entry..].partition_point(|&(it, _)| it <= end); // FIXME: this might be wrong?
(&self.spans[start_entry..][..end_entry]).iter().map(|&(_, s)| s)
}
+
+ pub fn iter(&self) -> impl Iterator<Item = (TextSize, S)> + '_ {
+ self.spans.iter().copied()
+ }
}