diff options
| author | Jeffrey Yasskin <[email protected]> | 2010-07-25 00:36:03 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-08-06 17:29:21 -0700 |
| commit | 3f6e8ffe64b57b0eaba6812208e94500422ca40c (patch) | |
| tree | bb6ed1f9b5ce9603c999c195d0754057e633599a /src/rt | |
| parent | Add an int->str conversion function. (diff) | |
| download | rust-3f6e8ffe64b57b0eaba6812208e94500422ca40c.tar.xz rust-3f6e8ffe64b57b0eaba6812208e94500422ca40c.zip | |
Implement _str.len() to return the number of bytes, rename it to byte_len(),
and add a test.
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 657109c6..d8d9b8d6 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -115,6 +115,12 @@ str_buf(rust_task *task, rust_str *s) return (char const *)&s->data[0]; } +extern "C" CDECL size_t +str_byte_len(rust_task *task, rust_str *s) +{ + return s->fill - 1; // -1 for the '\0' terminator. +} + extern "C" CDECL void * vec_buf(rust_task *task, type_desc *ty, rust_vec *v, size_t offset) { |