Fix Rust API examples in README

This commit is contained in:
Wilson Lin 2020-07-24 19:59:02 +10:00
parent 8733ca4b59
commit ec17be9be9
1 changed files with 4 additions and 4 deletions

View File

@ -52,7 +52,7 @@ If the `js-esbuild` feature is not enabled, `cfg.minify_js` will have no effect.
##### Use ##### Use
```rust ```rust
use minify_html::{Cfg, FriendlyError, in_place, copy, with_friendly_error, truncate}; use minify_html::{Cfg, Error, FriendlyError, in_place, copy, with_friendly_error, truncate};
fn main() { fn main() {
let mut code = b"<p> Hello, world! </p>".to_vec(); let mut code = b"<p> Hello, world! </p>".to_vec();
@ -64,21 +64,21 @@ fn main() {
// but leaves any original code after the minified code intact. // but leaves any original code after the minified code intact.
match in_place(&mut code, cfg) { match in_place(&mut code, cfg) {
Ok(minified_len) => {} Ok(minified_len) => {}
Err((error_type, error_position)) => {} Err(Error { error_type, position }) => {}
}; };
// Creates a vector copy containing only minified code // Creates a vector copy containing only minified code
// instead of minifying in-place. // instead of minifying in-place.
match copy(&code, cfg) { match copy(&code, cfg) {
Ok(minified) => {} Ok(minified) => {}
Err((error_type, error_position)) => {} Err(Error { error_type, position }) => {}
}; };
// Minifies a vector in-place, and then truncates the // Minifies a vector in-place, and then truncates the
// vector to the new minified length. // vector to the new minified length.
match truncate(&mut code, cfg) { match truncate(&mut code, cfg) {
Ok(()) => {} Ok(()) => {}
Err((error_type, error_position)) => {} Err(Error { error_type, position }) => {}
}; };
// Identical to `in_place` except with FriendlyError instead. // Identical to `in_place` except with FriendlyError instead.