[rust-dev] strings, slices and nulls

David Piepgrass qwertie256 at gmail.com
Fri Apr 20 18:20:59 PDT 2012

> My preference is to remove null termination:
> * I'm guessing most strings aren't passed to C. (What are the most
> common C string calls in rustc?)

It isn't just C, I'm afraid. It's pretty much every other language and OS,
too, because every language and OS is designed for C as the

* Each C function has its own expectations about character encoding

and allowed characters, so calls to C involve extra state-tracking or
> checks anyway.

I can't really agree. Some C functions have 'expectations about character
encoding and allowed characters' but many don't, and those that do don't
necessarily require 'extra state-tracking or checks' at run-time.

It would be best if rust could hide the 'implementation detail' of
null-termination, but for the foreseeable future, the potential interop
performance advantages probably outweigh a byte of wasted storage here and
there (after all, if one byte were important, we wouldn't want to use a
whole 4 bytes to hold the string length.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20120420/8b489ab0/attachment.html>

More information about the Rust-dev mailing list