Help with nom parsers

I have a problem with nom, the rust parsing library. I try to combine two parsers

alt((many0(tag("#")), space0))

The problem is that many0 returns a Vec and space0 returns a &str. Is there a way to still do this?

what do you want the combined parser to produce? depending on the expected behavior, you can combine them in different ways.

the most straight forward way is to map over one of the alternatives so both of them return the same type.

You could use alt((take_while(|c| c == '#'), space0)).


How would you use map to make them both &str?

I thought map worked like it does on iterators. But it doesn't, so it's clear to me now how to use them.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.