| Crates.io | better_cstr |
| lib.rs | better_cstr |
| version | 0.2.1 |
| created_at | 2025-04-24 20:37:15.627019+00 |
| updated_at | 2025-04-26 09:46:58.367221+00 |
| description | A better macro for working with C strings |
| homepage | |
| repository | https://github.com/iulian-rusu/better-cstr |
| max_upload_size | |
| id | 1647902 |
| size | 15,507 |
Are you tired of writing .as_ptr() after all your C-string literals?
Simply use the c! macro:
use better_cstr::c;
use std::ffi::{c_char, CStr};
fn main() {
let ptr: *const c_char = c!("Hello World");
unsafe {
println!("{:?}", CStr::from_ptr(ptr));
}
}
Supports any kind of string literal that does not contain a null byte.