#[unsafe(no_mangle)]pub extern "C" fn nstd_cstring_pop(
cstring: &mut NSTDCString<'_>,
) -> NSTDCharAvailable on crate feature
cstring only.Expand description
Removes the last character from a C string and returns it.
§Parameters:
NSTDCString *cstring- The C string.
§Returns
NSTDChar chr - The removed character, or null if the C string is empty.
§Example
use nstd_sys::{
alloc::NSTD_ALLOCATOR,
core::cstr::nstd_core_cstr_from_raw,
cstring::{nstd_cstring_from_cstr, nstd_cstring_pop},
NSTDChar,
};
unsafe {
let cstr = nstd_core_cstr_from_raw("123\0".as_ptr().cast());
let mut cstring = nstd_cstring_from_cstr(&NSTD_ALLOCATOR, &cstr).unwrap();
assert!(nstd_cstring_pop(&mut cstring) == b'3' as NSTDChar);
}