#minification #minifier

app rustminify-cli

A tool for minifying Rust code

1 unstable release

0.1.0 Aug 10, 2021

#8 in #minification

MIT/Apache

19KB
293 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

~1.8–2.5MB
~44K SLoC