const_c_str/lib.rs
1//! Safely create &CStr at compile time checked with [from_bytes_with_nul](std::ffi::CStr::from_bytes_with_nul)
2//! # Examples
3//! ```
4//! use const_c_str::c_str;
5//!
6//! #[cfg(feature = "const_cstr_unchecked")]
7//! const greeting: &std::ffi::CStr = c_str!("Hello World!");
8//! ```
9use proc_macro_hack::proc_macro_hack;
10
11#[proc_macro_hack]
12pub use const_c_str_impl::c_str;
13
14#[cfg(test)]
15mod tests {
16 use super::*;
17
18 #[cfg(feature = "const_cstr_unchecked")]
19 const greeting: &std::ffi::CStr = c_str!("Hello World!");
20
21 #[test]
22 fn test() {
23 println!("{:?}", c_str!("Testing!"));
24 }
25}