3 [![CI](https://github.com/upsuper/cstr/workflows/CI/badge.svg)](https://github.com/upsuper/cstr/actions)
4 [![Crates.io](https://img.shields.io/crates/v/cstr.svg)](https://crates.io/crates/cstr)
5 [![Docs](https://docs.rs/cstr/badge.svg)](https://docs.rs/cstr)
7 <!-- cargo-sync-readme start -->
9 A macro for getting `&'static CStr` from literal or identifier.
11 This macro checks whether the given literal is valid for `CStr`
12 at compile time, and returns a static reference of `CStr`.
14 This macro can be used to to initialize constants on Rust 1.46 and above.
22 let test = cstr!(b"hello\xff");
23 assert_eq!(test, CStr::from_bytes_with_nul(b"hello\xff\0").unwrap());
24 let test = cstr!("hello");
25 assert_eq!(test, CStr::from_bytes_with_nul(b"hello\0").unwrap());
26 let test = cstr!(hello);
27 assert_eq!(test, CStr::from_bytes_with_nul(b"hello\0").unwrap());
30 <!-- cargo-sync-readme end -->