The way I write code is not the way I read code, especially when I read code on the web (such as my own personal site). Lines that are fine in my editor are often too long for the web to comfortably read without swiping back and forth. This is why I run my Rust code through a custom rustfmt config.
First we need to write out a rustfmt toml file. We can use the default one like this:
The config looks like this, which I remove most of
The line I care most about is
max_width = 100 which I set to something like 60 for the web.
To use this configuration, on mac os I copy code into my clipboard and then use pbpaste to pipe it to rustfmt and back to my clipboard.
code before formatting:
code after formatting. Note that comments don't change, so if you have a particularly long comment you may need a nightly rustfmt feature to deal with that pertaining to comment wrapping.