#[no_mangle]
pub extern "C" fn nstd_string_pop(
    string: &mut NSTDString
) -> NSTDUnichar
Available on crate feature nstd_string only.
Expand description

Removes the last character from a string and returns it.

Parameters:

  • NSTDString *string - The string to pop.

Returns

NSTDUnichar chr - The removed character, or the Unicode replacement character on error.

Panics

This operation will panic if the string’s length in bytes exceeds NSTDInt’s max value.

Example

use nstd_sys::{
    core::str::nstd_core_str_from_raw_cstr_with_null,
    string::{nstd_string_from_str, nstd_string_pop},
};

unsafe {
    let str = nstd_core_str_from_raw_cstr_with_null("Hello, world!\0".as_ptr().cast());
    let mut string = nstd_string_from_str(&str);
    assert!(nstd_string_pop(&mut string) == 0);
}