cargo-expand 0.3.5

Wrapper around rustc --pretty=expanded. Shows the result of macro expansion and #[derive] expansion.
cargo-expand-0.3.5 is not a library.
Visit the last successful build: cargo-expand-1.0.38

cargo-expand

Build Status Latest Version

This is a wrapper around cargo rustc -- --pretty=expanded. Once installed, the command cargo expand prints out the result of macro expansion and #[derive] expansion applied to the current crate.

Installation

Install with cargo install cargo-expand.

This command optionally uses rustfmt to format the expanded output. If rustfmt is not available, the expanded code is not formatted. Install rustfmt with cargo install rustfmt.

This command optionally uses Pygments to colorize the expanded output. If Pygments is not available, the expanded code is not colorized. Install with pip install Pygments.

Example

$ cat src/main.rs

fn main() { println!("Hello, world!"); }


`$ cargo expand`

> ```rust
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
fn main() {
    ::std::io::_print(::std::fmt::Arguments::new_v1({
                                                        static __STATIC_FMTSTR:
                                                               &'static [&'static str]
                                                               =
                                                            &["Hello, world!\n"];
                                                        __STATIC_FMTSTR
                                                    },
                                                    &match () {
                                                        () => [],
                                                    }));
}

To expand a particular test target:

$ cargo expand --test test_something

To expand with rustfmt different from the one in $PATH:

$ RUSTFMT=/path/to/rustfmt cargo expand

To expand without rustfmt even though it is available in $PATH:

$ RUSTFMT= cargo expand

To color with pygmentize different from the one in $PATH:

$ PYGMENTIZE=/path/to/pygmentize cargo expand

To not color even though pygmentize is available in $PATH:

$ PYGMENTIZE= cargo expand

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in cargo-expand by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.