rustfmt

Chester Wyke September 02, 2023 Updated: April 15, 2025 #rust

Run rustfmt using nightly compiler

This might be needed if you want to use nighty only features

To format specific file

Does the whole file plus any files included in it like the rest of the library in this example

rustfmt +nightly src/lib.rs

To format all binary and library targets of your crate

cargo +nightly fmt

Using comment wrapping (comment_width)

Source: https://rust-lang.github.io/rustfmt/#comment_width

Needs this setting in the rustfmt.toml and must be uncommented to use but must tay commented when using the normal stable compiler as it hasn’t been standardized as yet.

# `wrap_comments` is unstable so to use you need to use nightly.
# Uncomment the line below then run `cargo +nightly fmt`

# wrap_comments = true