Skip to content

Commit 9b0f179

Browse files
authored
Relax lifetime constraints in language::embedding (#1225)
1 parent edbd5d5 commit 9b0f179

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/language/embedding.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,33 +80,37 @@ pub(crate) struct SimpleCapture<'a> {
8080
}
8181

8282
impl<'a> HtmlLike<'a> {
83-
pub fn start_script_in_range(
84-
&'a self,
83+
pub fn start_script_in_range<'this>(
84+
&'this self,
8585
start: usize,
8686
end: usize,
87-
) -> Option<impl Iterator<Item = &'a Capture<'a>>> {
87+
) -> Option<impl Iterator<Item = &'this Capture<'a>>> {
8888
filter_range(self.start_script.as_ref()?, start, end)
8989
}
9090

91-
pub fn start_style_in_range(
92-
&'a self,
91+
pub fn start_style_in_range<'this>(
92+
&'this self,
9393
start: usize,
9494
end: usize,
95-
) -> Option<impl Iterator<Item = &'a Capture<'a>>> {
95+
) -> Option<impl Iterator<Item = &'this Capture<'a>>> {
9696
filter_range(self.start_style.as_ref()?, start, end)
9797
}
9898

99-
pub fn start_template_in_range(
100-
&'a self,
99+
pub fn start_template_in_range<'this>(
100+
&'this self,
101101
start: usize,
102102
end: usize,
103-
) -> Option<impl Iterator<Item = &'a Capture<'a>>> {
103+
) -> Option<impl Iterator<Item = &'this Capture<'a>>> {
104104
filter_range(self.start_template.as_ref()?, start, end)
105105
}
106106
}
107107

108108
impl<'a> SimpleCapture<'a> {
109-
pub fn starts_in_range(&'a self, start: usize, end: usize) -> Option<&Capture<'a>> {
109+
pub fn starts_in_range<'this>(
110+
&'this self,
111+
start: usize,
112+
end: usize,
113+
) -> Option<&'this Capture<'a>> {
110114
filter_range(self.starts.as_ref()?, start, end).and_then(|mut it| it.next())
111115
}
112116

@@ -128,11 +132,11 @@ impl<'a> SimpleCapture<'a> {
128132
}
129133
}
130134

131-
fn filter_range<'a>(
132-
dataset: &'a [Capture<'a>],
135+
fn filter_range<'dataset, 'cap>(
136+
dataset: &'dataset [Capture<'cap>],
133137
start: usize,
134138
end: usize,
135-
) -> Option<impl Iterator<Item = &'a Capture<'a>>> {
139+
) -> Option<impl Iterator<Item = &'dataset Capture<'cap>>> {
136140
let pos = dataset
137141
.binary_search_by_key(&start, |cap| cap.start())
138142
.ok()?;

0 commit comments

Comments
 (0)