The simd optimized escape code
Crate v_escape provides two macros, new_escape!
and new_escape_sized!
,
that define a struct
with escaping functionalities. These macros are
optimized using simd by default, but this can be alter using sub-attributes.
In order to use v_escape you will have to call one of the two macros
to create a escape struct
. In this example, when using the macro
new_escape!(MyEscape, "62->bar");
a new a struct
MyEscape
will be created that every time its method MyEscape::fmt
is called
will replace all characters ">"
with "bar"
.
```rust
extern crate v_escape;
newescapesized!(MyEscape, "62->bar");
fn main() {
let s = "foo }
``` To check if rust version has simd functionality. The following code
has to be added to file fn main() {
enablesimdoptimizations();
} fn enablesimdoptimizations() {
if !isminversion("1.27.0").mapor(false, |(yes, _)| yes) {
println!("cargo:rustc-cfg=vescape_nosimd");
}
}
```print!("#{} : {}", escaped.size(), escaped);
build.rs
.
```rust
use versioncheck::ismin_version;