rustfmt

rustfmt, Rust's own formatter.

Formats
Rust
In ur.toml
[format.rust] style = "rustfmt"
Its options
https://rust-lang.github.io/rustfmt/

Formatted

cart.rs, as written
// What a cart costs.
fn subtotal(items:&[Item])->u64{items.iter().map(|item|item.price*item.quantity).sum()}
fn label(item:&Item)->String{item.name.clone()+" x"+&item.quantity.to_string()}
ur format --style rustfmt cart.rs
// What a cart costs.
fn subtotal(items: &[Item]) -> u64 {
    items.iter().map(|item| item.price * item.quantity).sum()
}
fn label(item: &Item) -> String {
    item.name.clone() + " x" + &item.quantity.to_string()
}

Try it in the playground →

Defaults

The shared options, as rustfmt sets them when nothing configures it. Its own names for them are read from its configuration files, but ur.toml sets them by the shared name only.

OptionDefaultrustfmt calls it
width100max_width
indent.width4tab_spaces
indent.stylehard_tabs
line-ending"auto"newline_style
trailing-comma.add"multiline"
trailing-comma.forces-breakfalse
quotes"preserve"
targetedition

Its own options

Set in a table named for it, such as [format.rustfmt], or in a language's table, as rustfmt = { ... }.

OptionDefaultWhat it does
use-small-heuristics"Default"How the widths below are set when not set themselves: as fractions of the line width (Default), not at all (Off), or to the whole line width (Max). Takes "Default", "Off", "Max".
fn-call-width60The widest a function call's arguments can be before they break across lines. Takes a number.
attr-fn-like-width70The widest a function-like attribute's arguments can be before they break across lines. Takes a number.
struct-lit-width18The widest a struct literal's body can be before it breaks across lines. Takes a number.
struct-variant-width35The widest a struct variant's body can be before it breaks across lines. Takes a number.
array-width60The widest an array literal can be before it breaks across lines. Takes a number.
chain-width60The widest a chain of method calls can be before it breaks, a call to a line. Takes a number.
single-line-if-else-max-width50The widest an if-else expression can be and stay on one line. Takes a number.
single-line-let-else-max-width50The widest a let-else statement's else block can be and stay on one line. Takes a number.
reorder-importstrueSort each group of consecutive use declarations. Takes true or false.
reorder-modulestrueSort each group of consecutive mod declarations. Takes true or false.
remove-nested-parenstrueRemove parentheses wrapped directly in other parentheses. Takes true or false.
short-array-element-width-threshold10The widest an array's elements can be for several to share a line when the array breaks. Takes a number.
match-arm-leading-pipes"Never"Whether each match arm begins with a |: Always, Never, or as written (Preserve). Takes "Always", "Never", "Preserve".
fn-params-layout"Tall"How a function's parameters break: as many to a line as fit (Compressed), all on one line or one to a line (Tall), or always one to a line (Vertical). Takes "Compressed", "Tall", "Vertical".
match-block-trailing-commafalsePut a comma after a match arm whose body is a block. Takes true or false.
style-editionThe Rust style edition to format in, which otherwise follows the code's edition. Takes "2015", "2018", "2021", "2024", "2027".
merge-derivestrueMerge an item's #[derive(...)] attributes into one. Takes true or false.
use-try-shorthandfalseWrite expr? in place of try!(expr). Takes true or false.
use-field-init-shorthandfalseWrite S { x } in place of S { x: x }. Takes true or false.
force-explicit-abitrueWrite extern "C" where extern alone is written. Takes true or false.
disable-all-formattingfalseLeave every file as written. Takes true or false.