On 11/8/13 9:26 AM, spir wrote:
What are the present implementations of strings and arrays in Rust? And
what about fixed size (esp for strings)?

    struct RustString {
        int size;
        int cap;
        char ptr[]
    };

    typedef *RustString ~str;

(If `~` were a valid identifier character in C, that is.) ;)

But Daniel did some performance measurements and found that this had suboptimal performance characteristics when compared to:

    struct ~str {
        char *ptr;
        int size;
        int cap;
    }

So we're changing to the latter.

By the way, I agree with Daniel that in an ideal world none of this would be baked into the compiler (except syntactically), and I would like to take steps to move to that world post Rust 1.0. However, given that we have dynamically sized types and as a result we have to define `~str` to mean *something*, we have to build in some representation into the compiler.

Patrick

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to