#[unsafe(no_mangle)]pub extern "C" fn nstd_string_pop(
string: &mut NSTDString<'_>,
) -> NSTDOptionalUnicharAvailable on crate feature
string only.Expand description
Removes the last character from a string and returns it.
§Parameters:
NSTDString *string- The string to pop.
§Returns
NSTDOptionalUnichar chr - The removed character on success.
§Example
use nstd_sys::{
alloc::NSTD_ALLOCATOR,
core::{optional::NSTDOptional, 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()).unwrap();
let mut string = nstd_string_from_str(&NSTD_ALLOCATOR, &str).unwrap();
assert!(nstd_string_pop(&mut string) == NSTDOptional::Some('\0'.into()));
}