#[no_mangle]
pub extern "C" fn nstd_cstring_pop(
    cstring: &mut NSTDCString
) -> NSTDChar
Available on crate feature nstd_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.

Panics

This function will panic if getting a pointer to the C string’s last character fails.

Example

use nstd_sys::{
    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(&cstr);
    assert!(nstd_cstring_pop(&mut cstring) == b'3' as NSTDChar);
}