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

Differentiate between InvalidData and UnexpectedEnd in std::str::Utf8Error #32584

Closed
troplin opened this issue Mar 29, 2016 · 1 comment
Closed
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@troplin
Copy link
Contributor

troplin commented Mar 29, 2016

For incremental "parsing" of string data (e.g. when reading from a stream) it would be helpful to know if an error is due to invalid bytes or premature end of data.

Something like:

enum Utf8ErrorKind {
    InvalidData,
    UnexpectedEnd,
}

impl Utf8Error {
    pub fn kind(&self) -> Utf8ErrorKind {...}
}

or something simpler, like:

impl Utf8Error {
    pub fn is_invalid_data(&self) -> bool {...}
}

As a side question, what's the preferred way for small feature requests like this one? Issue, PR, RFC or internals forum?

@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@Mark-Simulacrum
Copy link
Member

The two APIs exposed by Utf8Error today, valid_up_to and error_len should satisfy this issue, so I'm going to close. For reference: https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants