Function nstd_sys::core::str::nstd_core_str_get
source · #[no_mangle]
pub unsafe extern "C" fn nstd_core_str_get(
str: &NSTDStr,
pos: NSTDUInt
) -> NSTDOptionalUnicharAvailable on crate feature
nstd_core only.Expand description
Gets the NSTDUnichar at index pos in str.
Note
pos does not refer to the byte index of the character, but the NSTDUnichar index instead.
Parameters:
-
const NSTDStr *str- The string slice to index. -
NSTDUInt pos- The index of the character to get.
Returns
NSTDOptionalUnichar chr - The character at index pos, or none on error.
Safety
This operation can cause undefined behavior in the event that str’s data is invalid.
Example
use nstd_sys::core::str::{nstd_core_str_from_raw_cstr, nstd_core_str_get};
let s_str = "🦀🚀🦀!\0";
unsafe {
let str = nstd_core_str_from_raw_cstr(s_str.as_ptr().cast()).unwrap();
assert!(nstd_core_str_get(&str, 1).unwrap() == '🚀'.into());
}