#[no_mangle]
pub unsafe extern "C" fn nstd_string_from_str(
    str: &NSTDStr
) -> NSTDString
Available on crate feature nstd_string only.
Expand description

Creates an owned version of an unowned string slice.

Parameters:

  • const NSTDStr *str - The unowned string slice.

Returns

NSTDString string The new owned version of str.

Panics

This operation will panic if allocating fails.

Safety

The caller of this function must ensure that str’s data is valid for reads.

Example

use nstd_sys::{core::str::nstd_core_str_from_raw_cstr, string::nstd_string_from_str};

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