Open HenningHolmDE opened 1 week ago
Haha, nothing can hide from you :D This is great! But yes, I'm aware ...
If we look at imap-types
in isolation, the feature is fine. But as soon as you implement a codec, there is a very high chance you need functions to not go through try_from(...).unwrap()
.
In the past, unvalidated
was marked unsafe
and there was no unvalidated
feature. But... I felt like stretching the term unsafe
, and forcing people to #[allow(unsafe)]
.
So... the alternative was to feature-gate it. But... I don't think it makes much sense. When we say that after types comes a codec (that needs unvalidated
), all higher layers will have it. This is because imap-types
should only be in the dependency tree once (and features will add up.)
Long story short: We should remove the feature if we feel that there is no good use case for imap-types
w/o unvalidated
.
Another thought: Maybe someone could write a codec w/o using unvalidated
. Example for a tag: Read until space, and then call Tag::try_from
.
To clarify:
As the crate re-exports imap-types, these can be used without additional opt-in:
Here could be a misunderstanding: It should also work by use
ing imap-types
directly (w/o the re-export). This is because of Rust unifying dependencies accumulating features.
Hello, again! I renamed this issue because there is a similar one asking about the imap-types
re-export -- I hope this was in your sense! :-)
I feel that I probably want to un-gate the unvalidated
methods, i.e., remove the unvalidated
feature. Re-export seems like an orthogonal question. What do you think?
Removing the unvalidated
feature gate from imap-types
would remove the basis for my initial confusion. So yes, I'm fine with renaming the issue.
Currently,
imap-codec
depends on theunvalidated
feature ofimap-types
. As the crate re-exportsimap-types
, these can be used without additional opt-in:Is this already known to you? For me, this is not really a large problem, as the name and the documentation of the functions do provide sufficient information on how and when to use it safely.
However, does feature gating
unvalidated
inimap-types
still make much sense? (Without it, I would not have been suprised about the re-export.)