Function minify_html::in_place_str[][src]

pub fn in_place_str<'s>(code: &'s mut str, cfg: &Cfg) -> Result<&'s str, Error>

Minifies a str in-place and returns the new minified length. Any original code after the end of the minified code is left intact.

Arguments

  • code - A mutable str representing the source code to minify.
  • cfg - Configuration object to adjust minification approach.

Examples

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

let mut code = "<p>  Hello, world!  </p>".to_string();
let cfg = &Cfg {
    minify_js: false,
    minify_css: false,
};
match in_place_str(&mut code, cfg) {
    Ok(minified_len) => assert_eq!(&code, "<p>Hello, world!d!  </p>"),
    Err(Error { error_type, position }) => {}
};