Closed thunderbiscuit closed 4 years ago
Thanks for submitting this. I've been playing around with rustfmt to get a better handle on it, but there are a number of defaults that I really don't like about it. It is customizable, but unfortunately a lot of those features are only available in Rust nightly at this point.
I've tried really hard to keep this project on stable Rust, but I was able to use nightly just for the cargo fmt
command like so:
rustup component add rustfmt --toolchain nightly
cargo +nightly fmt
That works well enough, but unfortunately, it doesn't seem that there is a VS Code extension that lets you modify the command used when formatting on save. So maybe I'll add it as a git hook.
At any rate, I went through the list of customization options, and here's the list of changes I would like to make:
unstable_features = true
blank_lines_upper_bound = 2
fn_params_layout = "Compressed"
newline_style = "Unix"
overflow_delimited_expr = true
struct_lit_single_line = false
use_try_shorthand = true
where_single_line = true
If we put these in a rustfmt.toml
file in the main directory, that should give styles much closer to what I'm looking for. (As a side note, it gives me a warning about the fn_params_layout
, even though this is an option they list in their docs. Oh well.)
If you add that file and re-run the cargo +nightly fmt
again, then I will be happy to merge the changes in. (Make sure to pull in the latest changes to the branch first!)
Coming soon to a codebase near you.
This commit blindly runs the
cargo fmt
command. WIP, as some minor adjustments are likely needed.