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
nstd_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.
Panics
Panics if the current length in bytes exceeds NSTDInt’s max value.
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,
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());
let mut string = nstd_string_new();
assert!(nstd_string_push_str(&mut string, &str) == NSTD_ALLOC_ERROR_NONE);
}