-
Notifications
You must be signed in to change notification settings - Fork 93
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
Choice with different parser types #63
Comments
The first example you possible should typecheck fine, however it is possible you might have gotten a message that rust wasn't able to infer enough type information like this.
If that is the case the only problem is that rust could not figure out what type is being parsed. So if you want to parse a raw string you can add a line.
Which shows to Rust that the parser should parse a string. (The problem is that rust needs to specialize the parser for a single input type but the parser could equivalently parse an iterator of chars instead of a The reason your second example fails can be seen from the error message if you know what to look for. If you see this part it says it expected a reference (
So it should be:
(Since you are already specifying the length of the array you dont need to take that by
|
Thanks a ton for your help! I did some reading on trait objects and this was the cleanest code I could come up with that compiled:
Is this what you had in mind, or is there anything left that I can clean up here? |
Glad to be of help! You could remove the
Alternatively if you don't want to specify the length of the array you could just pass it as a slice (
(Haven't compiled it but it should work) |
okay, I managed to remove the casts with
I'm going to close this issue since it was never really an issue on the repo, but thanks again! |
I saw this mentioned in #54, but I'm not sure exactly how to get this to work. I'm a bit new to rust, so that's also probably related.
I'm trying to write something that can parse an escaped string, e.g.
"Hello \n \"World\""
and for this one of my helpers is this:You'll notice that the first 2
with
method calls are completely useless functionally, but they're the only thing making this expression type-check. I've been trying withbut I get these errors:
Do you have any idea what I'm doing wrong?
The text was updated successfully, but these errors were encountered: