CnxString struct

Cnx string type CnxString is a bounds safe, allocator aware, potentially dynamically allocated string type with significantly improved ergonomics over const char*s (aka cstrings), but maintains compatibility with them (CnxString is always null terminated). Provides similar functionality to C++'s std::string, but in C.

Example:

#include <Cnx/String.h>
#include <Cnx/IO.h>
// create default allocator (malloc allocates, free frees)
let allocator = cnx_allocator_new();
// could also call cnx_string_from("This is a string") since we're using the default
// allocator
let_mut string = cnx_string_from_with_allocator("This is a string", allocator);
cnx_string_append(&string, " with some extra text");
cnx_string_prepend(&string, "Hello world!\n");
// prints to stdout:
// Hello world!
// This is a string with some extra text
println("{}", string);

Public variables

cstring m_long
the long length string
usize m_length
The length of the string.
usize m_capacity
The capacity of the string.
char m_short
The short-length optimized string.
CnxAllocator m_allocator
The allocator to use for memory allocation.
const cnx_string_vtable_t* m_vtable
The function vector table of methods associated with CnxString