Skip to content

Missing From<&str> implementation when using custom span struct #225

Answered by zesterer
mainrs asked this question in Q&A
Discussion options

You must be logged in to vote

The reason that this doesn't work is that chumsky doesn't know how to assign instances of your custom span type to characters in the string. As you can see in the impl here, From<&str> for Stream is only defined for the Range<usize> span.

To solve this, you'll need to use Stream::from_iter. It's a relatively simple process, and the existing implementations in the crate should give you an idea of how to use it.

i.e: your final code should look like symbol().parse(Stream::from_iter(...)).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mainrs
Comment options

Answer selected by mainrs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants