#minify #minification #docs #minifying #rustminify

app rustminify-cli

A tool for minifying Rust code

1 unstable release

0.1.0 Aug 10, 2021

#12 in #minification

MIT/Apache

21KB
330 lines

rustminify

CI codecov dependency status

A tool for minifying Rust code.

rustminify-cli (Binary)

Crates.io Crates.io

 cargo install rustminify-cli
 rustminify --remove-docs <<EOF
//! crate-level doc

fn main() {
    println!("{}", module::f());
}

mod module {
    //! module-level doc

    /// doc for an item
    pub(crate) fn f() -> i32 {
        1 + 1
    }
}
EOF
fn main(){println!("{}",module::f());}mod module{pub(crate)fn f()->i32{1+1}}

rustminify (Library)

Crates.io Crates.io

 cargo add rustminify
use syn::parse_quote;

assert_eq!(
    r#"fn main(){println!("{}",module::f());}mod module{pub(crate)fn f()->i32{1+1}}"#,
    rustminify::minify_file(&rustminify::remove_docs(parse_quote! {
        //! crate-level doc

        fn main() {
            println!("{}", module::f());
        }

        mod module {
            //! module-level doc

            /// doc for an item
            pub(crate) fn f() -> i32 {
                1 + 1
            }
        }
    })),
);

License

Dual-licensed under MIT or Apache-2.0.

Dependencies

~4MB
~69K SLoC