Attempt to use common trait between variants #207
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important
This is in the ideation stage, not supposed to be merged without any real life proof of sense.
I made attempt to create a trait shared between
lossy
andlossless
variants ofRepository
, but this has following flaws:lossy
variant works nice as we can refer to member; I triedCow<>
but now dealing with factParagraph::get()
may fail become a problem (unwrap()
is plain wrong).Cow<>
is going to work for some cases, but may be a problem for some others, especially if wrapped inOption<>
.ok()
turns potential errors of late parsing intoNone
, I have doubts if it's acceptable.Problems with
lossless
structure:Paragraph
s are copied out ofDeb822
, there's not reference to themlossless::Repositories
storeDeb822
, I can only createlossless::Repository
from these paragraphs, there's not way to return reference to them (that's different than inlossy
variant).Maybe I'm heading in wrong direction (no modifications/setting taken into account yet), as this route gives me identical API of both variants, but with problems. Maybe the role of lossless variant should be to produce out lossy variant and accept one to perform modifications.
Can we discuss pros and cons?