Skip to content
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

make ParseErrorKind public #54

Closed
wants to merge 2 commits into from
Closed

make ParseErrorKind public #54

wants to merge 2 commits into from

Conversation

KodrAus
Copy link
Contributor

@KodrAus KodrAus commented Dec 23, 2015

It'd be nice to be able to run a match over the ParseError returned from an attempted parse. Making the ParseErrorKind public means you can match ParseError(ParseErrorKind::NotEnough)) for example.

@lifthrasiir
Copy link
Contributor

Hmm, I modelled ParseError after std::num::ParseFloatError which internal is private. I was reluctant to expose the error internals so far since it takes more time to stabilize errors. For the purpose of KodrAus/elasticsearch-rs#3, it might be better to implement a partial parsing function that will return a slice of the input instead of TooShort error; maybe ParseError::is_partial() method may be better suited for your use case.

@KodrAus
Copy link
Contributor Author

KodrAus commented Dec 24, 2015

Ahk thanks, I'll give that a go :) Great work on this library, it's really nice to work with

@KodrAus
Copy link
Contributor Author

KodrAus commented Dec 27, 2015

So I ended up using the Parsed struct which makes it easy to inspect the results of parsing, without having to let it fail first. Much better. Thanks!

@KodrAus KodrAus closed this Dec 27, 2015
@lifthrasiir
Copy link
Contributor

Glad to hear that! I originally intended to merge the PR (or work on my own) if something like ParseError::is_partial() is necessary, but it seems that Parsed is sort of a swiss-army knife :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants