On Apr 2, 2014, at 3:01 PM, Huon Wilson <dbau...@gmail.com> wrote:

> On 03/04/14 08:54, Patrick Walton wrote:
> 
>> What about strings? Should we be using `StrBuf` as well?
> 
> I don't see why not. The same arguments apply.

I agree. I was actually quite surprised to see that the type was named StrBuf, 
I assumed it was going to be Str just as Vec is not VecBuf.

I'm in full agreement with Huon on this matter. The standard libraries should 
return Vec<T> instead of ~[T] in pretty much every case (the only real 
exception I can think of is Vec<~[T]> because of the ability to convert to 
Vec<&[T]> or &[&T]] for free). Similarly I think we should be returning StrBuf 
instead of ~str in all cases. And finally, I think we should just name it Str 
instead of StrBuf.

If developers want to use ~[T] and ~str in their own code, that's fine, but the 
standard libraries should err on the side of preserving information (e.g. 
capacity) and providing a consistent experience. If there's one thing I really 
want to avoid above all else, it's confusing people about whether they should 
be using ~[T] or Vec<T>, because some standard library code uses one and some 
code uses the other.

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

Reply via email to