Closed MattesWhite closed 5 months ago
Merge the stream submodules into a top-level module stream equal to triple and quad.
I started trying this out, factorizing some of the code into a StatementSource
trait, then defining specializations of it as TripleSource
and QuadSource
. But I ran into the following problem:
One can not easily use the specialized traits in a trait bound. Instead of writing
pub fn consume_triple_source<TS: TripleSource>(mut ts: TS)
{ /*...*/ }
one needs to write
pub fn consume_triple_source<TS: TripleSource>(mut ts: TS)
where <TS::Mode as StreamingMode>::Item: UnsafeTriple
{ /*...*/ }
which is unintuitive and cumbersome. This does not go in the direction of making the API easier...
I put a summarized version of this problem in the playground.
This PR originates from the discussion in #49 starting with this comment.
Summary
*Sources
, e.g.:streaming_mode
).Problems
Normalizer<S>
one can only implement eitherIterator<Item = Triple> for Normalizer<S: TripleSource>
orIterator<Item = Quad> for Normalizer<S: QuadSource>
. Both together would result inconflicting implementation
.struct
incrate::triple::stream
and implementingQuadSource
incrate::quad::stream
requires the fields to bepub(crate)
at least.Solutions
For 1.: Maybe some overall abstraction for statements?
For 2.: Merge the
stream
submodules into a top-level modulestream
equal totriple
andquad
.