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