I've been digging through the combine crate trying to figure out how I can retrieve useful parser errors for UI feedback when I stumbled across multiple trait bounds like this example.
impl<Input, X, E> Positioned for Stream<Input, X>
where
Input: StreamOnce,
X: Positioner<Input::Token>,
E: StreamError<Input::Token, Input::Range>,
Input::Error: ParseError<Input::Token, Input::Range, X::Position, StreamError = E>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position, StreamError = E>,
{
#[inline]
fn position(&self) -> Self::Position {
self.positioner.position()
}
}
The bit I find confusing are the two Input::Error
trait bounds.
Input::Error: ParseError<Input::Token, Input::Range, X::Position, StreamError = E>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position, StreamError = E>,
Is this declaring that X::Position
and Input::Position
must be the same type? If so, that's a verbose means of expressing a relationship.