proc_strarray 1.1.0

Create const u8 array from str literal
Documentation

Procedural macros for str literals

Convert str to const [ u8; _ ] array

MIT OR Apache License Crates.io Version Crates.io MSRV Safe Rust Documentation Crates.io Downloads

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

  1. function str_repeat repeats str literal n times.
  2. function str_repeat0 repeats str literal n times and adds zero termination.

Misc functions

  1. 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);