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
) -> NSTDOptionalString<'_>
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
NSTDOptionalString string
- The new string on success, or an uninitialized “none” variant if
allocating fails.
§Example
use nstd_sys::{alloc::NSTD_ALLOCATOR, string::nstd_string_new_with_cap};
let string = unsafe { nstd_string_new_with_cap(&NSTD_ALLOCATOR, 20) };