🍺 BREW Explorer

← all formulae

cargo-expand

brew install cargo-expand v1.0.123 Apache-2.0 OR MIT

Show what Rust code looks like with macros expanded

66
30-day installs · #4117
144
90-day · #4782
588
365-day · #4785
3.1k
★ GitHub stars · updated 2mo ago

Build dependencies

GitHub topics

cargo

Links

Raw metadata
{
  "aliases": [],
  "alternatives": [],
  "build_dependencies": [
    "rust"
  ],
  "categories": [],
  "caveats": null,
  "conflicts_with": [],
  "dependencies": [],
  "deprecated": 0,
  "deprecation_reason": null,
  "desc": "Show what Rust code looks like with macros expanded",
  "disable_reason": null,
  "disabled": 0,
  "enrichment_fetched_at": "2026-06-20T23:36:08+00:00",
  "first_seen": "2026-06-20T23:34:18+00:00",
  "full_name": "cargo-expand",
  "github_default_branch": "master",
  "github_last_commit_at": "2026-06-20T22:21:36Z",
  "github_readme_excerpt": "# cargo-expand\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-dtolnay/cargo--expand-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/dtolnay/cargo-expand)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/cargo-expand.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/cargo-expand)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/dtolnay/cargo-expand/ci.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/dtolnay/cargo-expand/actions?query=branch%3Amaster)\n\nOnce installed, the following command prints out the result of macro expansion\nand `#[derive]` expansion applied to the current crate.\n\n```console\n$ cargo expand\n```\n\nThis is a wrapper around the more verbose compiler command:\n\n```console\n$ cargo rustc --profile=check -- -Zunpretty=expanded\n```\n\n## Installation\n\nInstall with **`cargo install cargo-expand`**.\n\nThis command optionally uses [rustfmt] to format the expanded output. The\nresulting code is typically much more readable than what you get from the\ncompiler. If rustfmt is not available, the expanded code is not formatted.\nInstall rustfmt with **`rustup component add rustfmt`**.\n\n[rustfmt]: https://github.com/rust-lang/rustfmt\n\n## Example\n\n#### `$ cat src/main.rs`\n\n```rust\n#[derive(Debug)]\nstruct S;\n\nfn main() {\n    println!(\"{:?}\", S);\n}\n```\n\n#### `$ cargo expand`\n\n```rust\n#![feature(prelude_import)]\n#[prelude_import]\nuse std::prelude::v1::*;\n#[macro_use]\nextern crate std;\nstruct S;\n#[automatically_derived]\n#[allow(unused_qualifications)]\nimpl ::core::fmt::Debug for S {\n    fn fmt(\u0026self, f: \u0026mut ::core::fmt::Formatter) -\u003e ::core::fmt::Result {\n        match *self {\n            S =\u003e {\n                let mut debug_trait_builder = f.debug_tuple(\"S\");\n                debug_trait_builder.finish()\n            }\n        }\n    }\n}\nfn main() {\n    {\n        ::std::io::_print(::core::fmt::Arguments::new_v1(\n      ",
  "github_repo": "dtolnay/cargo-expand",
  "github_stars": 3095,
  "github_topics": [
    "cargo"
  ],
  "homepage": "https://github.com/dtolnay/cargo-expand",
  "homepage_og_description": null,
  "homepage_og_image": null,
  "homepage_title": null,
  "installs_30d": 66,
  "installs_365d": 588,
  "installs_90d": 144,
  "keg_only": 0,
  "keg_only_reason": null,
  "last_seen": "2026-06-20T23:34:18+00:00",
  "license": "Apache-2.0 OR MIT",
  "llm_generated_at": null,
  "llm_model": null,
  "name": "cargo-expand",
  "oldnames": [],
  "one_liner": null,
  "optional_dependencies": [],
  "rank_30d": 4117,
  "rank_365d": 4785,
  "rank_90d": 4782,
  "raw_hash": "83fd3509d4ec2a24",
  "recommended_dependencies": [],
  "revision": 0,
  "ruby_source_path": "Formula/c/cargo-expand.rb",
  "tap": "homebrew/core",
  "test_dependencies": [
    "rustup"
  ],
  "uses_from_macos": [],
  "version_head": "HEAD",
  "version_stable": "1.0.123",
  "versioned_formulae": [],
  "why_use_this": null
}