Use static dispatch for Formatter methods in Rust code
#689
Evian-Zhang
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, methods of
Formatteraccept a&mut dyn FormatterOutputfor writing formatted output. Why don't we use&mut impl FormatterOutput, which could leverage the benefits of inlining brought by static dispatch? Is this decision because of MSRV?I tried to text-replace all
&mut dyn FormatterOutputto&mut impl FormatterOutput, and things work fine in the latest Rust stable compiler, only the tests cannot compile since we cannot makeFormatterinto a trait object any more. But this can be fixed by adjusting test code (and I can't figure out any usecases where downstream users would useBox<dyn Formatter>).If this change is acceptable, I would further fix the code in unit test to make it pass the tests, and file a PR afterwards. :)
Beta Was this translation helpful? Give feedback.
All reactions