2 stable releases
1.1.0 | Jul 31, 2024 |
---|---|
1.0.0 | Jul 29, 2024 |
#532 in Procedural macros
60 downloads per month
12KB
164 lines
Procedural macros for str literals
Convert str to const [ u8; _ ] array
Procedural macro proc_strarray::make_array
creates const u8 array from str literal.
Variant proc_strarray::make_array0
creates zero terminated u8 array.
Repeat str
- function
str_repeat
repeats str literal n times. - function
str_repeat0
repeats str literal n times and adds zero termination.
Misc functions
- Utility function
str_len
returns length of str literal.
Usage
// This code will create const array of u8
// named STRU from content of "stru" str literal.
use proc_strarray::make_array;
make_array!(STRU, "stru");
// check if newly created array have length 4
assert_eq!(STRU.len(), 4);
// check created array if first character is 's'
assert_eq!(STRU[0], 's' as u8);
Dependencies
~2MB
~43K SLoC