mozilla/rust — pull request #7599 by Aatch (2013-07-05 06:37:25+00:00)
Title: Add a StringRef and a VecRef

Adds types for representing either a static string/vector or an owned string/vector.

The vector implements most convenience methods available to other vectors, and the rest can be accessed via the .as_slice() method.

I ran into some issues with the string implementation trying to implement `StrSlice` on it, since the borrow checker has difficulty relating the lifetimes. All the standard methods are still available via the .as_slice() method, as before.

Both implementations have methods for converting to an owned version, and both have a `to_owned_consume` that consumes the type and only does an allocation if necessary.

Closes #6874

----

PS: I'm not sure on the names, if anybody has any better suggestions, I'm happy to change them.