Add trimming option for the de::from_* functions #561
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.
Reference #520 (comment).
So I did the feature in ONE way possible because there are many different ways this can be implemented.
I choose to modify the current functions for this to work but this can change easily and I will explain the other alternatives I've thought about at the end. What I really wanted to discuss here is if the logic of extending the
StartTrimmer
to a generic start and endTrimmer
is fine? And if giving to all the differentReader
is also good? I choose a rather generic and extensible solution. Just want to know if you don't see it made like that or if this is rather fine.For the different way of expressing the config parameter, I've chosen to add a parameter to
from_str
but its breaks the current API so it might not be the best solution. I thought of 2 other ways of doing this.The first one: add another function
from_str_option
that will do the exact same as the currentfrom_str
but will take the extra parameter, and the oldfrom_str
will just callfrom_str_option
with a default Trimmer.The second option: Transform
from_str
to a macro to be able to have theTrimmer
parameter optional, and if not given construct a default one.When I talk about
from_str
it is the high-level one not the inner function ofDeserializer