reduce code redundancy for the encoding
feature
#262
Labels
encoding
Issues related to support of various encodings of the XML documents
enhancement
help wanted
A lot of methods are defined twice in the code, once with
encoding
enabled, and once without it.Some of these methods have different result types (direct value vs. Result), and this propagate to methods calling them (which must call the former with or without a
?
, depending).(NB: as pointed out in #180, only private method should have a change of signature, but this is orthogonal, I think)
I suggest the following change:
T
, private methods in the non-encoding
configuration should returnstd::result::Result<T, std::convert::Infallible>
, which after compilation is equivalent toT
, but is syntactically is still a result.Error
should implementFrom<Infallible>
(again, this is merely to please the compiler during parsing: the‘from
method will contain anunreachable!()
statement, sinceInfallible
has no value)?
, regardless of the presence/absence of theencoding
feature. That way, they don't need two different implementation. The compiler will, however, ignore the?
when the underlying error type isInfallible
(i.e. whenencoding
is disabled).edited fixed the path of
Infallible
The text was updated successfully, but these errors were encountered: