Crate v_escape provides a macro, new!
that define a struct
with
escaping functionality. These macros are optimized using simd by default,
but this can be alter using sub-attributes.
Quick start
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!(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"
.
!;
#
new
Pairs syntax
v_escape uses a simple syntax to replace characters
with their respective quotes. The tuple is named Pair
,
and several can be defined, referred as Pairs
. The syntax to define
Pairs
consists of a character, followed
by the delimiter ->
, followed by the substitution quote
and the delimiter ||
(last delimiter is optional):
([character]->[quote], )*
-
character
: Character to substitute. Acceptsi8+
from0
toi8::MAX
and accepts the following formats: decimal (49), hexadecimal (0x31), octal (0o61) or character (#1). Note: Numbers are read in ASCII:#6->foo
-
quote
: Characters that will replacecharacter
!;
#
new
!;
#
new
!;
#
new
!;
#
new
In the following example more than 16 pairs are given, this exceeds simd's boundary. If simd optimization is wanted, ranges must be enabled (default) or an error will be thrown. It is possible to not use ranges but simd optimization has to be disabled.
!;
#
new
For debugging purposes, sub-attribute print
, can be set to true
to print generated code
!;
#
new