Procedural macros for str literals
Create array from str
Procedural macro proc_strarray::make_array
creates const u8 array from str literal.
Variant proc_strarray::make_array0
creates zero terminated u8 array.
Macro make_array takes three arguments:
- name of array to be created
- str literal
- expected length of str literal (optional argument, can be omitted)
Repeat str
- macro
str_repeat
repeats str literal n times. - macro
str_repeat0
repeats str literal n times and adds zero termination.
Return str length
- macro
str_len
returns length of str literal. - macro
str_len0
returns length of zero terminated str literal.
Usage
// This code will create const array of u8
// named STRU from content of "stru" str literal.
use make_array;
make_array!;
// check if newly created array have length 4
assert_eq!;
// check created array if first character is 's'
assert_eq!;
Documentation
rustdoc generated documentation can be found at docs.rs
License and MSRV
proc_strarray uses same license as Rust. MSRV is 1.57 and it will stay for all 1.X versions.