[rust-dev] strings, slices and nulls
graydon at mozilla.com
Mon Apr 23 12:04:12 PDT 2012
On 12-04-22 06:02 PM, Joe Groff wrote:
> 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.
That is the current plan. I'm in the process of implementing it.
> 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.
Copying a pointer (as is required by the FFI) and copying a string are
different operations. The latter is what we're trying to avoid, and it's
costly, yes. Particularly when in inner loops, as C calls often are.
More information about the Rust-dev