-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow nested_in
to accept a parser that emits a different type of tokens
#689
Comments
Hmm. I can see this use-case, certainly. |
I think it's just a matter of changing around the type params to allow for it? fn nested_in<IB: Input<'a>, EB: ParserExtra<'a, IB>, B: Parser<'a, IB, I, EB>>(
self,
other: B,
) -> NestedIn<Self, B, O, E>
where
Self: Sized,
{
NestedIn {
parser_a: self,
parser_b: other,
phantom: EmptyPhantom::new(),
}
} |
I've had a go at implementing this, and it does seem to work, but it comes with a constraint: specifically, that the I've pushed up a commit on |
Updated, this seems to be related but I'm not sure how (maybe the same change needs to be made for let interpolation= expr
.nested_in::<_, StringInput, StringExtra>(select_ref! {
StringToken::Interpolation(inner) = e => {
inner.as_slice().spanned(SimpleSpan::to_end(&e.span()))
},
})
.map(|t| StringPart::InterpolatedExpr(t.into()));
|
There's not enough information there to be useful. My hunch is that one of the constraints I listed is being violated somehow. If you have a small failing example I can run, that would be useful too. |
Can we discuss on Discord or something? I don't want to clog up the issue tracker with debugging. |
Sure. I'm active on the Rust Community Discord, in the #langdev channel. To anybody else reading this, any important information will be fed back here. |
I have this use case, where
expr
is a parser with(Token, Span)
as the input, and the surrounding function returns a parser that takes in `(StringToken, Span)However, this errors because
nested_in
expects the parser being passed in to both accept and return the same type, which clashes here.The text was updated successfully, but these errors were encountered: