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.

--width N sets the line cap for rustfmt and joined one-liners, which defaults to 160.

On a normal run, fastfmt creates or updates the target project's rustfmt.toml with disable_all_formatting = true. 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 the width cap and contains no comments or multiline tokens. The supported constructs are:

  • Ordinary blocks, including function, closure, if/else, and loop bodies, with at most one statement, optionally followed by a tail expression.
  • match, struct, and enum bodies with up to three arms, fields, or variants.
  • Single-item impl blocks.

Semicolons are preserved exactly. A statement-position else starts on a new line. An if/else used as a value stays on one line.

Joins run innermost-first and repeat until nothing more can join. This allows nested constructs to collapse fully. Blocks used as match-arm bodies stay expanded. Blocks containing comments or multiline strings retain rustfmt's output.

Metadata

Release files for fastfmt 0.1.6

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.6
File Size Uploaded Provenance Actions
fastfmt-0.1.6.tar.gz 21.8 kB With provenance Details for fastfmt-0.1.6.tar.gz

Built distributions (wheels)

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

Total release size: 1.7 MB

Release files / fastfmt-0.1.6.tar.gz

Download URL fastfmt-0.1.6.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c9dff4bf160b28e1b7614e195b51887f46f28a3f7d5188b5a8bc4b1215588733
BLAKE2b-256 checksum
How to use checksums
b01757589f28b384f75c37b2c72ed2c0105c04d0dd2c327dc0a62f346f6249f1
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.6-py3-none-manylinux_2_28_x86_64.whl

Download URL fastfmt-0.1.6-py3-none-manylinux_2_28_x86_64.whl
Size 592.3 kB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
95d2e533eaadda8238388c6e67ad41c2fc7ee5581733727610480c411403d22b
BLAKE2b-256 checksum
How to use checksums
90e5f6df982fc6d40a75d1f8b08759d1952abf0d4c3917b2edfeb5a5fadbff62
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.6-py3-none-manylinux_2_28_aarch64.whl

Download URL fastfmt-0.1.6-py3-none-manylinux_2_28_aarch64.whl
Size 584.9 kB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
5a4139b00f19bf3426ec83d4fe1c342e87efdf32a55e672ed5e0576c58a3771e
BLAKE2b-256 checksum
How to use checksums
e7094320dd585537b39eba1b24f9d59c0c792346d5c7dbd3b0393e0f20992e5b
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.6-py3-none-macosx_11_0_arm64.whl

Download URL fastfmt-0.1.6-py3-none-macosx_11_0_arm64.whl
Size 550.1 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e852f57ba9859e21a213be4a3afea37e7df0ca0fe3d6c46b671653d6203f7663
BLAKE2b-256 checksum
How to use checksums
550f6833deb90e114805f4a70fe71dccf44468e22c3eb31cc96948863828410b
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.6

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.6.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