You can change the behavior of rustfmt with a configuration to set your preferred styles. Add the rustfmt.toml configuration file to your project. The defaults of the current version can be described with the following configuration file contents:
max_width = 100
hard_tabs = false
tab_spaces = 4
newline_style = "Auto"
use_small_heuristics = "Default"
reorder_imports = true
reorder_modules = true
remove_nested_parens = true
edition = "2015"
merge_derives = true
use_try_shorthand = false
use_field_init_shorthand = false
force_explicit_abi = true
Most parameters have descriptive names, but if you want to read a description of the parameters, you can pass the --help=config argument to rustfmt to see the details. You can create a rustfmt.toml file and set parameters that are different from the default values.
Often, code style checking is the first step of a CI script, because it's the fastest check and is best done before a long compilation process. There is also another code check that we should do before compilation—lint checking.