chloro 0.6.4

A minimal Rust code formatter
Documentation
# chloro

[![crates.io](https://img.shields.io/crates/v/chloro.svg)](https://crates.io/crates/chloro)
[![documentation](https://docs.rs/chloro/badge.svg)](https://docs.rs/chloro)
[![MIT/Apache-2.0 licensed](https://img.shields.io/crates/l/chloro.svg)](./LICENSE)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/lmmx/chloro/master.svg)](https://results.pre-commit.ci/latest/github/lmmx/chloro/master)
[![free of syn](https://img.shields.io/badge/free%20of-syn-hotpink)](https://github.com/fasterthanlime/free-of-syn)<!-- blazon -->
[![Dependencies: 32](https://img.shields.io/badge/cargo%20tree-32-blue)](https://crates.io/crates/chloro)
[![Binary Size: 1.6M](https://img.shields.io/badge/build%20size-1.6M-green)](https://crates.io/crates/chloro)<!-- /blazon -->

chloro is a minimal Rust code formatter.

## Motivation

For when you want to format two source files in a consistent way, as fast as possible.

## How it works

Using [rowan][rowan] from the rust-analyzer project, which can give both green and red trees.
The latter are notoriously expensive, but a formatter should only need the former.

Proof of concept library/CLI to explore a fast and low memory code formatter [WIP],
with use cases of code diffing in mind.

[rowan]: https://github.com/rust-analyzer/rowan

## Rustfmt Conformance

Diff 'leaderboard' for how well formatting with chloro matches rustfmt,
as tested on rust-analyzer's [crates][ra-crates]:

[ra-crates]: https://github.com/rust-lang/rust-analyzer/blob/master/crates/syntax/src/ast/generated.rs

<!-- just: conf-md -->$'\n'**Summary:** +122,844 / -13,303

| **Top 5 <del>Removed</del> Lines** | **Top 5 <ins>Added</ins> Lines** |
|---|---|
| `- }` × 111<br>`- },` × 93<br>`- );` × 87<br>`- ///` × 72<br>`- },` × 64<br> | `+}` × 75<br>`+///` × 75<br>`+ },` × 65<br>`+ }` × 65<br>`+ }` × 52<br> |

### Top 20 Most Impacted Files

| Rank | Size Rank | Diff Rank | Impact |   +   |    -    | File |
|------|-----------|-----------|--------|-------|---------|------|
| 1 | 9 | 1 | 42.8% | 1,606 | 3,751 | [`rust_analyzer/src_config`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/rust_analyzer/src_config.diff |
| 2 | 2 | 17 | 2.2% | 241 | 11,083 | [`ide/src_hover_tests`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide/src_hover_tests.diff |
| 3 | 4 | 9 | 4.7% | 281 | 6,011 | [`ide_assists/src_handlers_extract_function`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide_assists/src_handlers_extract_function.diff |
| 4 | 3 | 14 | 3.9% | 247 | 6,390 | [`hir/src_lib`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/hir/src_lib.diff |
| 5 | 16 | 4 | 15.1% | 445 | 2,950 | [`rust_analyzer/src_lsp_to_proto`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/rust_analyzer/src_lsp_to_proto.diff |
| 6 | 7 | 12 | 6.6% | 256 | 3,859 | [`ide/src_goto_definition`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide/src_goto_definition.diff |
| 7 | 62 | 2 | 55.0% | 808 | 1,469 | [`hir_expand/src_builtin_derive_macro`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/hir_expand/src_builtin_derive_macro.diff |
| 8 | 31 | 5 | 17.1% | 388 | 2,263 | [`hir_ty/src_next_solver_interner`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/hir_ty/src_next_solver_interner.diff |
| 9 | 8 | 32 | 4.8% | 180 | 3,758 | [`ide/src_rename`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide/src_rename.diff |
| 10 | 94 | 3 | 41.4% | 465 | 1,124 | [`ide/src_navigation_target`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide/src_navigation_target.diff |
| 11 | 1 | 516 | 0.1% | 12 | 19,633 | [`ide_db/src_generated_lints`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide_db/src_generated_lints.diff |
| 12 | 47 | 11 | 15.0% | 260 | 1,739 | [`ide_assists/src_handlers_auto_import`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide_assists/src_handlers_auto_import.diff |
| 13 | 76 | 7 | 27.3% | 348 | 1,277 | [`hir_def/src_lib`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/hir_def/src_lib.diff |
| 14 | 14 | 42 | 5.3% | 160 | 3,037 | [`ide_assists/src_handlers_generate_function`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide_assists/src_handlers_generate_function.diff |
| 15 | 34 | 20 | 10.2% | 221 | 2,174 | [`ide_assists/src_handlers_add_missing_match_arms`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide_assists/src_handlers_add_missing_match_arms.diff |
| 16 | 15 | 49 | 4.9% | 149 | 3,018 | [`ide/src_references`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide/src_references.diff |
| 17 | 20 | 40 | 6.6% | 167 | 2,534 | [`ide_assists/src_handlers_extract_variable`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide_assists/src_handlers_extract_variable.diff |
| 18 | 23 | 37 | 6.9% | 172 | 2,506 | [`rust_analyzer/src_handlers_request`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/rust_analyzer/src_handlers_request.diff |
| 19 | 151 | 6 | 42.5% | 349 | 821 | [`rust_analyzer/tests_slow-tests_ratoml`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/rust_analyzer/tests_slow-tests_ratoml.diff |
| 20 | 12 | 81 | 3.6% | 115 | 3,237 | [`ide_completion/src_render`]https://github.com/lmmx/chloro/blob/master/chloro-core/tests/conformance/snapshots/ra/ide_completion/src_render.diff |$'\n'<!-- /just: conf-md -->

## Installation

Add chloro to your `Cargo.toml`:
```toml
[dependencies]
chloro = "0.5"
```

#### CLI Installation

- pre-built binary: `cargo binstall chloro` (requires [cargo-binstall][cargo-binstall]),
- build from source: `cargo install chloro --features cli`

[cargo-binstall]: https://github.com/cargo-bins/cargo-binstall

## License

This project is licensed under either of:

- Apache License, Version 2.0, ([LICENSE-APACHE]LICENSE-APACHE or <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT]LICENSE-MIT or <http://opensource.org/licenses/MIT>)

at your option.