[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5598":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},5598,"rustfmt","rust-lang\u002Frustfmt","rust-lang","Format Rust code","https:\u002F\u002Frust-lang.github.io\u002Frustfmt\u002F",null,"Rust",6870,1020,49,720,0,13,48,3,76.33,"Apache License 2.0",false,"main",true,[26,27,28,5],"codeformatter","formatter","rust","2026-06-12 04:00:25","# rustfmt [![linux](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frustfmt\u002Factions\u002Fworkflows\u002Flinux.yml\u002Fbadge.svg?event=push)](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frustfmt\u002Factions\u002Fworkflows\u002Flinux.yml) [![mac](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frustfmt\u002Factions\u002Fworkflows\u002Fmac.yml\u002Fbadge.svg?event=push)](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frustfmt\u002Factions\u002Fworkflows\u002Fmac.yml) [![windows](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frustfmt\u002Factions\u002Fworkflows\u002Fwindows.yml\u002Fbadge.svg?event=push)](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frustfmt\u002Factions\u002Fworkflows\u002Fwindows.yml) [![crates.io](https:\u002F\u002Fimg.shields.io\u002Fcrates\u002Fv\u002Frustfmt-nightly.svg)](https:\u002F\u002Fcrates.io\u002Fcrates\u002Frustfmt-nightly)\n\nA tool for formatting Rust code according to style guidelines.\n\nIf you'd like to help out (and you should, it's a fun project!), see\n[Contributing.md](Contributing.md) and our [Code of\nConduct](CODE_OF_CONDUCT.md).\n\nYou can use rustfmt in Travis CI builds. We provide a minimal Travis CI\nconfiguration (see [here](#checking-style-on-a-ci-server)).\n\n## Quick start\n\nYou can run `rustfmt` with Rust 1.24 and above.\n\n### On the Stable toolchain\n\nTo install:\n\n```sh\nrustup component add rustfmt\n```\n\nTo run on a cargo project in the current working directory:\n\n```sh\ncargo fmt\n```\n\n### On the Nightly toolchain\n\nFor the latest and greatest `rustfmt`, nightly is required.\n\nTo install:\n\n```sh\nrustup component add rustfmt --toolchain nightly\n```\n\nTo run on a cargo project in the current working directory:\n\n```sh\ncargo +nightly fmt\n```\n\n## Limitations\n\nRustfmt tries to work on as much Rust code as possible. Sometimes, the code\ndoesn't even need to compile! In general, we are looking to limit areas of\ninstability; in particular, post-1.0, the formatting of most code should not\nchange as Rustfmt improves. However, there are some things that Rustfmt can't\ndo or can't do well (and thus where formatting might change significantly,\neven post-1.0). We would like to reduce the list of limitations over time.\n\nThe following list enumerates areas where Rustfmt does not work or where the\nstability guarantees do not apply (we don't make a distinction between the two\nbecause in the future Rustfmt might work on code where it currently does not):\n\n* a program where any part of the program does not parse (parsing is an early\n  stage of compilation and in Rust includes macro expansion).\n* Macro declarations and uses (current status: some macro declarations and uses\n  are formatted).\n* Comments, including any AST node with a comment 'inside' (Rustfmt does not\n  currently attempt to format comments, it does format code with comments inside, but that formatting may change in the future).\n* Rust code in code blocks in comments.\n* Any fragment of a program (i.e., stability guarantees only apply to whole\n  programs, even where fragments of a program can be formatted today).\n* Code containing non-ascii unicode characters (we believe Rustfmt mostly works\n  here, but do not have the test coverage or experience to be 100% sure).\n* Bugs in Rustfmt (like any software, Rustfmt has bugs, we do not consider bug\n  fixes to break our stability guarantees).\n\n\n## Running\n\nYou can run Rustfmt by just typing `rustfmt filename` if you used `cargo\ninstall`. This runs rustfmt on the given file, if the file includes out of line\nmodules, then we reformat those too. So to run on a whole module or crate, you\njust need to run on the root file (usually mod.rs or lib.rs). Rustfmt can also\nread data from stdin. Alternatively, you can use `cargo fmt` to format all\nbinary and library targets of your crate.\n\nYou can run `rustfmt --help` for information about available arguments.\nThe easiest way to run rustfmt against a project is with `cargo fmt`. `cargo fmt` works on both\nsingle-crate projects and [cargo workspaces](https:\u002F\u002Fdoc.rust-lang.org\u002Fbook\u002Fch14-03-cargo-workspaces.html).\nPlease see `cargo fmt --help` for usage information.\n\nYou can specify the path to your own `rustfmt` binary for cargo to use by setting the`RUSTFMT` \nenvironment variable. This was added in v1.4.22, so you must have this version or newer to leverage this feature (`cargo fmt --version`)\n\n### Running `rustfmt` directly\n\nTo format individual files or arbitrary codes from stdin, the `rustfmt` binary should be used. Some\nexamples follow:\n\n- `rustfmt lib.rs main.rs` will format \"lib.rs\" and \"main.rs\" in place\n- `rustfmt` will read a code from stdin and write formatting to stdout\n  - `echo \"fn     main() {}\" | rustfmt` would emit \"fn main() {}\".\n\nFor more information, including arguments and emit options, see `rustfmt --help`.\n\n### Verifying code is formatted\n\nWhen running with `--check`, Rustfmt will exit with `0` if Rustfmt would not\nmake any formatting changes to the input, and `1` if Rustfmt would make changes.\nIn other modes, Rustfmt will exit with `1` if there was some error during\nformatting (for example a parsing or internal error) and `0` if formatting\ncompleted without error (whether or not changes were made).\n\n\n\n## Running Rustfmt from your editor\n\n* [Vim](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frust.vim#formatting-with-rustfmt)\n* [Emacs](https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frust-mode)\n* [Sublime Text 3](https:\u002F\u002Fpackagecontrol.io\u002Fpackages\u002FRustFmt)\n* [Atom](atom.md)\n* [Visual Studio Code](https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=rust-lang.rust-analyzer)\n* [IntelliJ or CLion](intellij.md)\n\n\n## Checking style on a CI server\n\nTo keep your code base consistently formatted, it can be helpful to fail the CI build\nwhen a pull request contains unformatted code. Using `--check` instructs\nrustfmt to exit with an error code if the input is not formatted correctly.\nIt will also print any found differences. (Older versions of Rustfmt don't\nsupport `--check`, use `--write-mode diff`).\n\nA minimal Travis setup could look like this (requires Rust 1.31.0 or greater):\n\n```yaml\nlanguage: rust\nbefore_script:\n- rustup component add rustfmt\nscript:\n- cargo build\n- cargo test\n- cargo fmt --all -- --check\n```\n\nSee [this blog post](https:\u002F\u002Fmedium.com\u002F@ag_dubs\u002Fenforcing-style-in-ci-for-rust-projects-18f6b09ec69d)\nfor more info.\n\n## How to build and test\n\n`cargo build` to build.\n\n`cargo test` to run all tests.\n\nTo run rustfmt after this, use `cargo run --bin rustfmt -- filename`. See the\nnotes above on running rustfmt.\n\n\n## Configuring Rustfmt\n\nRustfmt is designed to be very configurable. You can create a TOML file called\n`rustfmt.toml` or `.rustfmt.toml`, place it in the project or any other parent\ndirectory and it will apply the options in that file. See `rustfmt\n--help=config` for the options which are available, or if you prefer to see\nvisual style previews, [GitHub page](https:\u002F\u002Frust-lang.github.io\u002Frustfmt\u002F).\n\nBy default, Rustfmt uses a style which conforms to the [Rust style guide][style\nguide] that has been formalized through the [style RFC\nprocess][fmt rfcs].\n\nConfiguration options are either stable or unstable. Stable options can always\nbe used, while unstable ones are only available on a nightly toolchain, and opt-in.\nSee [GitHub page](https:\u002F\u002Frust-lang.github.io\u002Frustfmt\u002F) for details.\n\n### Rust's Editions\n\nThe `edition` option determines the Rust language edition used for parsing the code. This is important for syntax compatibility but does not directly control formatting behavior (see [Style Editions](#style-editions)).\n\nWhen running `cargo fmt`, the `edition` is automatically read from the `Cargo.toml` file. However, when running `rustfmt` directly, the `edition` defaults to 2015. For consistent parsing between rustfmt and `cargo fmt`, you should configure the `edition` in your `rustfmt.toml` file:\n\n```toml\nedition = \"2018\"\n```\n\n### Style Editions\n\nThis option is inferred from the [`edition`](#rusts-editions) if not specified.\n\nSee [Rust Style Editions] for details on formatting differences between style editions.\nrustfmt has a default style edition of `2015` while `cargo fmt` infers the style edition from the `edition` set in `Cargo.toml`. This can lead to inconsistencies between `rustfmt` and `cargo fmt` if the style edition is not explicitly configured.\n\nTo ensure consistent formatting, it is recommended to specify the `style_edition` in a `rustfmt.toml` configuration file. For example:\n\n```toml\nstyle_edition = \"2024\"\n```\n[Rust Style Editions]: https:\u002F\u002Fdoc.rust-lang.org\u002Fnightly\u002Fstyle-guide\u002Feditions.html?highlight=editions#rust-style-editions\n[Rust Style Guide]: https:\u002F\u002Fdoc.rust-lang.org\u002Fnightly\u002Fstyle-guide\u002F\n[RFC 3338]: https:\u002F\u002Frust-lang.github.io\u002Frfcs\u002F3338-style-evolution.html\n\n## Tips\n\n* To ensure consistent parsing between `cargo fmt` and `rustfmt`, you should configure the [`edition`](#rusts-editions) in your `rustfmt.toml` file.\n* To ensure consistent formatting between `cargo fmt` and `rustfmt`, you should configure the [`style_edition`](#style-editions) in your `rustfmt.toml` file.\n\n* For things you do not want rustfmt to mangle, use `#[rustfmt::skip]`\n* To prevent rustfmt from formatting a macro or an attribute,\n  use `#[rustfmt::skip::macros(target_macro_name)]` or\n  `#[rustfmt::skip::attributes(target_attribute_name)]`\n\n  Example:\n\n    ```rust\n    #![rustfmt::skip::attributes(custom_attribute)]\n\n    #[custom_attribute(formatting , here , should , be , Skipped)]\n    #[rustfmt::skip::macros(html)]\n    fn main() {\n        let macro_result1 = html! { \u003Cdiv>\n    Hello\u003C\u002Fdiv>\n        }.to_string();\n    ```\n* When you run rustfmt, place a file named `rustfmt.toml` or `.rustfmt.toml` in\n  target file directory or its parents to override the default settings of\n  rustfmt. You can generate a file containing the default configuration with\n  `rustfmt --print-config default rustfmt.toml` and customize as needed.\n* After successful compilation, a `rustfmt` executable can be found in the\n  target directory.\n* If you're having issues compiling Rustfmt (or compile errors when trying to\n  install), make sure you have the most recent version of Rust installed.\n\n* You can change the way rustfmt emits the changes with the --emit flag:\n\n  Example:\n\n  ```sh\n  cargo fmt -- --emit files\n  ```\n\n  Options:\n\n  | Flag |Description| Nightly Only |\n  |:---:|:---:|:---:|\n  | files | overwrites output to files | No |\n  | stdout | writes output to stdout | No |\n  | coverage | displays how much of the input file was processed | Yes |\n  | checkstyle | emits in a checkstyle format | Yes |\n  | json | emits diffs in a json format | Yes |\n\n## License\n\nRustfmt is distributed under the terms of both the MIT license and the\nApache License (Version 2.0).\n\nSee [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.\n\n[rust]: https:\u002F\u002Fgithub.com\u002Frust-lang\u002Frust\n[fmt rfcs]: https:\u002F\u002Fgithub.com\u002Frust-dev-tools\u002Ffmt-rfcs\n[style guide]: https:\u002F\u002Fdoc.rust-lang.org\u002Fnightly\u002Fstyle-guide\u002F\n","rustfmt 是一个用于根据风格指南格式化 Rust 代码的工具。其核心功能包括自动调整代码布局、缩进、空格等，以符合统一的编码规范，支持跨平台使用（Linux、macOS 和 Windows）。该工具可以集成到 CI\u002FCD 流程中，如 Travis CI，确保团队成员提交的代码风格一致。适用于所有需要保持代码整洁一致性的 Rust 开发场景，无论是个人项目还是大型协作开发。",2,"2026-06-11 03:04:16","top_language"]