It may be possible to eliminate a lot of `fmt::Display` code by using [parse-display](https://github.com/frozenlib/parse-display/tree/master?tab=readme-ov-file#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 the `fmt_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 as `value.fmt(f)` because the first case creates a new `Formatter` instance, whereas the second case reuses the one passed as an argument to `Display::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.
Just to keep them a bit more consistent.
Note that there are a lot of code duplications here - but I do not know if they are worth consolidating, and/or any perf implications.
As seen in the https://rust.godbolt.org/z/Y8djWsq1P - write! macro produces significantly more code than a write_str call, so this change should have somewhat better performance. To my knowledge, a lot of ppl tried to solve this optimization in the compiler, but no luck yet, so may help compiler ourselves for now.
These are a bit more questionable but still keep things cleaner a bit, at least in some cases?
Most of these were the result of `cargo clippy --fix -- -W clippy::use_self`
To keep with DRY principle, I think it makes it a bit less redundant to reuse the Self::<associated_type_name> structure in the well known trait implementations - keeps it consistent with the trait decl too.