Skip to content

Stream / Input trait #7

Description

@adamthedash

Currently we impl on concrete input types &[u8] and &str. Due to the orphan rule this disallows anyone from implementing Parser<CustomType> for any existing parsers.
There's also a lot of duplication of parser logic, (see Take* and Skip* parsers) due to how the input needs to be sliced.
It would be better to introduce an Input type, roughly with the following:

trait Input {
type Owned;
fn len() -> usize;
fn slice(n: usize) -> Self;
...
}

We'll have to be careful that the extra degree of freedom doesn't create extra headaches for type inference at the call site.

References:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions