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.
It may be possible to eliminate a lot of
fmt::Display
code by using parse-display crate. In the first iteration, it can replace many display traits for the simple cases of constants and formatted inner values. In the more advanced, it should be possible to format iterators, and if the issue I proposed get implemented, might even cover many of thefmt_sse
functions.Note that I made a few unit tests for the migration purposes - just to see that the result is identical. We may want to remove at least some of them later on as being too trivial.
One aspect that may need discussion:
write!(f, "{value}")
is not the same asvalue.fmt(f)
because the first case creates a newFormatter
instance, whereas the second case reuses the one passed as an argument toDisplay::fmt
function.In some cases, it may break if formatter contains padding or number formatting configuration that will or won't be passed to the nested object.
parse-display
seem to always generate a new Formatter, but Oxigraph uses a lot of.fmt
calls - which might actually be a bug.