[−][src]Function minify_html::copy
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 = b"<p> Hello, world! </p>".to_vec(); let cfg = &Cfg { minify_js: false, }; match copy(&code, cfg) { Ok(minified) => { assert_eq!(code, b"<p> Hello, world! </p>".to_vec()); assert_eq!(minified, b"<p>Hello, world!".to_vec()); } Err(Error { error_type, position }) => {} };