3 ms·
Similar to what pascal do it. And certainly NOT how C do it. The best internals (imho) is just a array (see, on rust): https://doc.rust-lang.org/src/alloc/str
by mamcx 6y ago
Similar to what pascal do it. And certainly NOT how C do it.
The best internals (imho) is just a array (see, on rust):
https://doc.rust-lang.org/src/alloc/string.rs.html#278-280 https://doc.rust-lang.org/src/alloc/string.rs.html#278-280
This allow a lot of efficient operations and the possibility of use views (for substrings).
Where thing get nasty is all the unicode stuff. So even if the internal are simply, provide a good API that allow to use unicode correctly is what is more complicated.
I think here "proper implementation of strings" must take in account if is proper unicode, ascii or raw. Rust and other modern languages choose UTF-8 and I think this is the best posible option.