nstd_core_cstr_first

Function nstd_core_cstr_first 

Source
#[unsafe(no_mangle)]
pub const extern "C" fn nstd_core_cstr_first( cstr: &NSTDCStr, ) -> *const NSTDChar
Available on crate feature core only.
Expand description

Returns a pointer to the first character in a C string slice, or null if it is empty.

§Parameters:

  • const NSTDCStr *cstr - The C string slice.

§Returns

const NSTDChar *first - If present, a pointer to the first character in the C string slice.

§Example

use nstd_sys::{
    core::cstr::{nstd_core_cstr_first, nstd_core_cstr_from_raw},
    NSTDChar,
};

unsafe {
    let cstr = nstd_core_cstr_from_raw("Tea\0".as_ptr().cast());
    assert!(*nstd_core_cstr_first(&cstr) == b'T' as NSTDChar);
}