| Crates.io | cargo-derivefmt |
| lib.rs | cargo-derivefmt |
| version | 0.2.0 |
| created_at | 2023-03-12 01:05:40.614909+00 |
| updated_at | 2025-12-20 06:36:42.368411+00 |
| description | Format derives alphabetically |
| homepage | |
| repository | https://github.com/dcchut/derivefmt |
| max_upload_size | |
| id | 807655 |
| size | 60,481 |
A tool for ordering derives in Rust code.
cargo-derivefmt ensures that your derives are written in alphabetical order.
// Before: pure chaos.
#[derive(Debug, PartialEq, Ord, Clone, Copy)]
struct S;
// After: blissful order.
#[derive(Clone, Copy, Debug, Ord, PartialEq)]
struct S;
That's it! That's all this does.
This package is currently implemented using rust-analyzer internals, so cannot be published on crates.io.
cargo install --locked --git https://github.com/dcchut/cargo-derivefmt --bin cargo-derivefmt
cargo derivefmt
cargo derivefmt --manifest-path /path/to/Cargo.toml
cargo derivefmt --file path/to/src.rs
cargo derivefmt --file path/to/src.rs --file /path/to/another.rs
Passing a folder formats all .rs files contained within it and its subfolders:
cargo derivefmt --file /path/to/folder/