Update README

This commit is contained in:
Wilson Lin 2020-06-19 14:26:39 +10:00
parent 4e416074e7
commit 786bac2849
1 changed files with 10 additions and 6 deletions

View File

@ -52,31 +52,35 @@ hyperbuild = "0.1.1"
##### Use ##### Use
```rust ```rust
use hyperbuild::hyperbuild; use hyperbuild::{FriendlyError, hyperbuild};
fn main() { fn main() {
let mut code = b"<p> Hello, world! </p>".to_vec(); let mut code = b"<p> Hello, world! </p>".to_vec();
// `hyperbuild` minifies a slice in-place and returns the new minified length, but leaves any original code after the minified code intact. // Minifies a slice in-place and returns the new minified length,
// but leaves any original code after the minified code intact.
match hyperbuild(&mut code) { match hyperbuild(&mut code) {
Ok(minified_len) => {} Ok(minified_len) => {}
Err((error_type, error_position)) => {} Err((error_type, error_position)) => {}
}; };
// `hyperbuild_copy` creates a vector copy containing only minified code instead of minifying in-place. // Creates a vector copy containing only minified code
// instead of minifying in-place.
match hyperbuild_copy(&code) { match hyperbuild_copy(&code) {
Ok(minified) => {} Ok(minified) => {}
Err((error_type, error_position)) => {} Err((error_type, error_position)) => {}
}; };
// `hyperbuild_truncate` minifies a vector in-place, and then truncates the vector to the new minified length. // Minifies a vector in-place, and then truncates the
// vector to the new minified length.
match hyperbuild_truncate(&mut code) { match hyperbuild_truncate(&mut code) {
Ok(()) => {} Ok(()) => {}
Err((error_type, error_position)) => {} Err((error_type, error_position)) => {}
}; };
// `hyperbuild_friendly_error` is identical to `hyperbuild` except the error is a FriendlyError instead. // Identical to `hyperbuild` except with FriendlyError instead.
// `code_context` is a string of a visual representation of the source code with line numbers and position markers to aid in debugging syntax issues, and should be printed. // `code_context` is a string of a visual representation of the source,
// with line numbers and position markers to aid in debugging syntax.
match hyperbuild_friendly_error(&mut code) { match hyperbuild_friendly_error(&mut code) {
Ok(minified_len) => {} Ok(minified_len) => {}
Err(FriendlyError { position, message, code_context }) => { Err(FriendlyError { position, message, code_context }) => {