3 ms·
But the code isn't equivalent. The C code just has a pointer to a manually allocated buffer, while the Rust does the equivalent of zeroing out (or leaving unini
by LinAGKar 5y ago
But the code isn't equivalent. The C code just has a pointer to a manually allocated buffer, while the Rust does the equivalent of zeroing out (or leaving uninitialized) a C++ std::string. Akin to:
auto name = reinterpret_cast<std::string >(malloc(sizeof(std::string)));
memset(name, 0, sizeof(std::string);
*name = "basic";
But on the stack.