> C++'s `string` and `vector<T>` are objects containing two or three pointers.
For that one pays performance penalty in C++ as string and vector
instances are passed by references resulting in double indirection
when accessing the elements. I suppose it could help to think about
strings in Rust similar to variable-sized structs in C like:
struct MyString {
unsigned int bytelength;
unsigned int data[];
};
As in Rust such struct cannot be instantiated and one typically uses
malloc/alloca to allocate instances and then just pass around the
resulting pointers.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev