[rust-dev] strings, slices and nulls

Joe Groff arcata at gmail.com
Sun Apr 22 18:02:53 PDT 2012


On Apr 20, 2012, at 8:33 PM, Kevin Cantu <me at kevincantu.org> wrote:

> The cost isn't an extra byte of storage.  The cost is that every slice
> will have to be a copy+append.
>
> Both D and Go have special slice types to store pointers and offsets
> to the underlying arrays/strings, so slice operations can avoid that
> hit, IIRC.

It would definitely be more forward-thinking to use slices as the
primary native mechanism for passing around strings and
memory-contiguous sequences in general. Regions should help make
data-sharing slices safe to use. Since C calls already require that
arguments be copied to the FFI context, does making null-terminated
copies of strings add that much additional overhead? Copying is pretty
cheap on modern platforms.

-Joe


More information about the Rust-dev mailing list