Closed
Description
I'd like to write a ParseElem
implementation that returns references to the original input - something like:
impl ParseElem<'input> for Vec<Token> {
type Element = &'input Token;
fn parse_elem(&'input self, pos: usize) -> RuleResult<Self::Element> {
match self.get(pos) {
Some(tok) => RuleResult::Matched(pos + 1, tok),
None => RuleResult::Failed,
}
}
}
But unfortunately with the current ParseElem
definition I don't think this is possible. Is there any reason ParseElem
doesn't have an explicit lifetime specifier (like ParseSlice
does)? And if not, would you accept a PR to implement it?
Metadata
Metadata
Assignees
Labels
No labels
Activity
kevinmehall commentedon Aug 29, 2021
That seems fine. I don't think there's a reason it was omitted besides that the
str
and[T]
impls didn't need it because they clone the elements.I'd accept a PR. It is a breaking change, but it can go in 0.8.
kevinmehall commentedon Jan 2, 2022
Fixed by f09fc34