[rust-dev] strings, slices and nulls

Graydon Hoare graydon at mozilla.com
Wed Apr 18 13:37:51 PDT 2012

On 12-04-18 12:43 PM, Niko Matsakis wrote:

> I can see the practicality of null-terminating, but I would really like
> to preserve the flexibility to reverse that decision in the future.
> Forcing people to go through str::as_bytes() to observe the null
> terminating seems like a win—except that I'd probably call it as_cstr()
> or something like that, to emphasize it's null-terminated-ness.

Right, but .. you can still observe it by allocating a str/5 in a record
and noticing that it takes 6 bytes (i.e. with sizeof). Tolerable?


More information about the Rust-dev mailing list