jinxdash / prettier-plugin-rust

Prettier Rust is an opinionated code formatter that autocorrects bad syntax.
MIT License
180 stars 8 forks source link

The formatting of the `use` statement is different from cargo-fmt #27

Closed timongh closed 1 year ago

timongh commented 1 year ago

Input code

`use std::io::{   stdin  ,    stdout  ,   Write   };`

Output code

`use std::io::{ stdin, stdout, Write };`

Additional context

The results generated by executing cargo fmt: use std::io::{stdin, stdout, Write};

jinxdash commented 1 year ago

All style decisions are adapted from Prettier core (typescript), so differences from rustfmt are expected

Note that you can also use prettier in the CLI (requires NodeJS):

npm install --global prettier-plugin-rust prettier

Then instead of cargo fmt, you can format your project using this command:

prettier --write **/*.rs

https://github.com/jinxdash/prettier-plugin-rust#project-integration