Function nstd_sys::string::nstd_string_push_str
source · #[no_mangle]
pub unsafe extern "C" fn nstd_string_push_str(
string: &mut NSTDString<'_>,
str: &NSTDStr
) -> NSTDAllocErrorAvailable on crate feature
string only.Expand description
Appends a string slice to the end of a string.
Parameters:
-
NSTDString *string- The string. -
const NSTDStr *str- The string slice to append to the end ofstring.
Returns
NSTDAllocError errc - The allocation operation error code.
Safety
This function will cause undefined behavior in the case where str’s data is no longer valid.
Example
use nstd_sys::{
alloc::{NSTDAllocError::NSTD_ALLOC_ERROR_NONE, NSTD_ALLOCATOR},
core::str::nstd_core_str_from_raw_cstr,
string::{nstd_string_new, nstd_string_push_str},
};
unsafe {
let str = nstd_core_str_from_raw_cstr("Hello, 🌎!\0".as_ptr().cast()).unwrap();
let mut string = nstd_string_new(&NSTD_ALLOCATOR);
assert!(nstd_string_push_str(&mut string, &str) == NSTD_ALLOC_ERROR_NONE);
}