Provides fixed-size string types [StrArray<N>] and [CStrArray<N>].
[StrArray] serves as the str equivalent of [u8; N], offering a Deref
to &str and ensuring the UTF-8 invariant is always upheld, but with a
size known at compile time. This is designed for no_std environments
or where strings are always a certain size.
The [str_array!] macro provides a compile-time-checked way to
build [StrArray] values from string literals and constants.
Similarly, [CStrArray] and [cstr_array!] can construct a nul-terminated
C string safely on the stack.
Features
no_stdsupport - disable default features to use- Optional
allocandstdfeatures constsupport- C string support
- Full test coverage
Examples
use ;
// Create from a literal using the macro. The length is inferred.
let s1 = str_array!;
assert_eq!;
assert_eq!;
// Or create from a &str with an panicking length check.
let s2: = new;
assert_eq!;
assert_eq!;
// Or create from bytes with a UTF-8 check.
let s3 = from_utf8.unwrap;
assert_eq!;
// Or define an item with an inferred length.
str_array!
assert_eq!;