Function minify_html::copy[][src]

pub fn copy(code: &[u8], cfg: &Cfg) -> Result<Vec<u8>, Error>

Copies a slice into a new Vec and minifies it, returning the Vec. The resulting Vec will only contain minified code.

Arguments

  • code - A slice of bytes representing the source code to minify.
  • cfg - Configuration object to adjust minification approach.

Examples

use minify_html::{Cfg, Error, copy};

let mut code: &[u8] = b"<p>  Hello, world!  </p>";
let cfg = &Cfg {
    minify_js: false,
    minify_css: false,
};
match copy(&code, cfg) {
    Ok(minified) => {
        assert_eq!(code, b"<p>  Hello, world!  </p>");
        assert_eq!(minified, b"<p>Hello, world!".to_vec());
    }
    Err(Error { error_type, position }) => {}
};