On 11/8/13 3:11 PM, Daniel Micay wrote:
The only way you could avoid pointer indirection is by making the
element length part of the type, like fixed-size vectors. For strings,
there's not really a clearly meaningful element length (bytes? code
points? graphemes?).
An alternate vector/string doing small string optimization makes more
sense to me.
I think it's worth thinking about how to allow for custom vector/string
implementations in this scenario. There are a couple of directions I can
see us going:
1. Keep `~[T]` as today and implement overloadable literal syntax for
`SmallString`/`SmallVector`.
Or:
2. Implement things like `SmallString`/`SmallVector` as custom smart
pointers that know how to store elements of a vector inline. These kind
of custom smart pointers would be hard-wired to particular kinds of
DSTs. So, for example, we could imagine:
let x: SmallVector<[int]> = new(SmallVector) [ 1, 2, 3, 4 ];
Option (2) is intriguing to me, because it allows us to possibly get
away with not having literal syntax and taking advantage of DSTs to get
us the benefits of custom vector/string representations. But it seems
too good to be true :) There may be something I'm missing...
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev