Function nstd_sys::string::nstd_string_new_with_cap
source · #[no_mangle]
pub extern "C" fn nstd_string_new_with_cap(
allocator: &NSTDAllocator,
cap: NSTDUInt
) -> NSTDString<'_>Available on crate feature
string only.Expand description
Creates a new string initialized with the given capacity.
Parameters:
-
const NSTDAllocator *allocator- The memory allocator. -
NSTDUInt cap- The number of bytes to allocate ahead of time.
Returns
NSTDString string - The new string.
Example
use nstd_sys::{alloc::NSTD_ALLOCATOR, string::nstd_string_new_with_cap};
let string = unsafe { nstd_string_new_with_cap(&NSTD_ALLOCATOR, 20) };