Skip to main content

fastfmt

cargo fmt, then put the one-liners back.

Stable rustfmt expands constructs such as short function bodies, statement-position if/else, and short match or struct bodies. Some options for keeping them compact are nightly-only. Others have no rustfmt option. fastfmt runs rustfmt through stdin, then rejoins comment-free constructs within its size and width limits, giving fastai-style compact Rust from a stable toolchain.

Install and use

pip install fastfmt

The wheel contains one cargo-fastfmt binary and no Python code. With the binary on PATH, Cargo recognizes it as a subcommand:

cargo fastfmt            # format the current directory tree in place
cargo fastfmt --check    # exit 1 listing files that would change; write nothing
cargo fastfmt src lib.rs # format specific files or directories

rustfmt must also be on PATH. Install it with rustup component add rustfmt.

Traversal respects .gitignore, .git/info/exclude, global Git ignores, and .ignore files, including for explicitly supplied paths. Hidden entries and target/ directories are skipped. Ignored files, including rustfmt.toml, are never written.

--width N sets the hard line cap, defaulting to 160. Signatures, imports, lists and expression continuations pack up to that cap. Each joined body must also fit a budget of min(120, N) by itself, not counting the signature or condition before it. A closure body joins only when its enclosing call or chain also fits that budget.

On a normal run, fastfmt creates or updates each formatted project's rustfmt.toml with disable_all_formatting = true, unless that config is ignored. This prevents cargo fmt or editor rustfmt runs from undoing the compact formatting. fastfmt overrides the setting for its own pass. No pre-existing config file is needed.

--check never writes the config. It reports a missing or disabled guard as a required update.

Comment joining

Opt in to joining hard-wrapped comment paragraphs in Cargo.toml:

[package.metadata.fastfmt]
join_comments = true

Use [workspace.metadata.fastfmt] for workspace-wide defaults. Package settings override the workspace setting, including join_comments = false. Comment joining is off when neither sets it.

Consecutive standalone //, ///, or //! comments with matching indentation and markers are treated as Markdown. Soft paragraph breaks become spaces, including wrapped continuations within list items and block quotes. Paragraphs can exceed --width; fastfmt does not rewrap them.

Lists, code blocks, tables, headings, inline code, raw HTML, and explicit Markdown hard breaks (a trailing backslash or two spaces) retain their structure. Use lists for separate points and code fences for diagrams, disabled code, or other layout-sensitive text. Unmarked line breaks within prose are joined. Trailing comments and block comments are not joined.

Joining rules

A construct can join onto one line when it fits its budget and contains no comments or multiline tokens. The supported constructs are:

  • Blocks, including function, closure, if/else, loop and match-arm bodies, with at most one statement, optionally followed by a tail expression or by break, continue or return. A block whose first statement is an if/else chain doesn't join.
  • Single-item impl blocks.
  • Struct fields, enum variants, simple match arms, nested use declarations and other comma-separated lists, limited by width rather than item count.

Semicolons are preserved exactly. Statement chains and multiline/over-width value chains separate else if and compact else branches after compact bodies. Multiline branch braces keep } else { attached. Value chains that fit entirely on one line stay inline.

Continuation packing erases existing breaks within expressions, parameter/argument lists and declaration headers while they fit the hard line cap. Multiline bodies and lists remain separate islands, with list interiors packed independently. This keeps meaningful closure bodies readable without expanding every method or enclosing parenthesis. The packer never invents breakpoints or splits tokens.

Inside opaque macro token trees, only tiny => { ... } groups with at most one direct semicolon and no nested token groups join, and their tokens are never rewritten. Parenthesised and bracketed macro groups that contain commas pack their existing interior lines without changing tokens. Brace-delimited macro groups never pack.

Joins repeat so nested constructs can collapse fully. Comments and multiline strings are protected boundaries; packing is skipped when it would require altering their contents or indentation.

Metadata

Release files for fastfmt 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastfmt 0.1.7
File Size Uploaded Provenance Actions
fastfmt-0.1.7.tar.gz 30.6 kB With provenance Details for fastfmt-0.1.7.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for fastfmt 0.1.7
File Interpreter ABI Platform Actions
fastfmt-0.1.7-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for fastfmt-0.1.7-py3-none-manylinux_2_28_x86_64.whl
fastfmt-0.1.7-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for fastfmt-0.1.7-py3-none-manylinux_2_28_aarch64.whl
fastfmt-0.1.7-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for fastfmt-0.1.7-py3-none-macosx_11_0_arm64.whl

Total release size: 3.8 MB

Release files / fastfmt-0.1.7.tar.gz

Download URL fastfmt-0.1.7.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fb9350c32ed180e85030c51c86ec7707d9d3ce3798c1111344d89e6d5069b3ae
BLAKE2b-256 checksum
How to use checksums
8ef721cc747d1c4b94ed1a01d72a282aa4cf3bc1cc38ac58b364e0d09d4f204a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / fastfmt-0.1.7-py3-none-manylinux_2_28_x86_64.whl

Download URL fastfmt-0.1.7-py3-none-manylinux_2_28_x86_64.whl
Size 1.3 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
74f5c99614ce6dbb771edddad42c0de5911f9a48e44877ea932bf31ba5643044
BLAKE2b-256 checksum
How to use checksums
c84964433b24a7eea1d5c45102ec3c991a9eed7d6443e7339948d234291283a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / fastfmt-0.1.7-py3-none-manylinux_2_28_aarch64.whl

Download URL fastfmt-0.1.7-py3-none-manylinux_2_28_aarch64.whl
Size 1.3 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
af2539a58c8c45e6e29a5f90b6018d77cf0719d629598cc68594827ee55115ec
BLAKE2b-256 checksum
How to use checksums
0c2c6e65ba080a8303e357695e5279dd22476d33dbd624b3624ac2d7554a3ebb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / fastfmt-0.1.7-py3-none-macosx_11_0_arm64.whl

Download URL fastfmt-0.1.7-py3-none-macosx_11_0_arm64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d16fe2376ea15d9cc8f3d494a49bff12261004b8ff7f0ec269185ad387784c77
BLAKE2b-256 checksum
How to use checksums
e39a61e86b7590e56ca5f7af76ba62e9a3ca199e03108ff04145b3c8eab9e364
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for fastfmt 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for fastfmt-0.1.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page