Skip to content

dcchut/cargo-derivefmt

Repository files navigation

cargo-derivefmt

A tool for ordering derives in Rust code.

Motivation

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.

Installation

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

Usage

Formatting the current crate

cargo derivefmt 

Formatting a different crate

cargo derivefmt --manifest-path /path/to/Cargo.toml

Formatting a single file

cargo derivefmt --file path/to/src.rs

Formatting multiple files

cargo derivefmt --file path/to/src.rs --file /path/to/another.rs

Formatting folders

Passing a folder formats all .rs files contained within it and its subfolders:

cargo derivefmt --file /path/to/folder/

Roadmap

  • Better identification of files to format (particularly in the context of a cargo project).
  • Better handling of comments.

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages