You can automatically format rust code using $ cargo fmt. You will first need to install rustfmt using $ rustup component add rustfmt.
$ cargo fmt
rustfmt
$ rustup component add rustfmt