Skip to content

iulian-rusu/better-cstr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Better CStr Macro

github crates.io docs.rs

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.

About

A better macro for working with C string

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages