pub fn truncate(code: &mut Vec<u8>, cfg: &Cfg) -> Result<(), Error>
Expand description
Minifies a Vec in-place, truncating it to the minified length.
§Arguments
code
- A slice of bytes representing the source code to minify.cfg
- Configuration object to adjust minification approach.
§Examples
use minify_html_onepass::{Cfg, Error, truncate};
let mut code = b"<p> Hello, world! </p>".to_vec();
let cfg = &Cfg {
minify_js: false,
minify_css: false,
};
match truncate(&mut code, cfg) {
Ok(()) => assert_eq!(code, b"<p>Hello, world!".to_vec()),
Err(Error { error_type, position }) => {}
};