about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@gmail.com>2010-07-25 00:36:03 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-08-06 17:29:21 -0700
commit3f6e8ffe64b57b0eaba6812208e94500422ca40c (patch)
treebb6ed1f9b5ce9603c999c195d0754057e633599a /src/rt/rust_builtin.cpp
parent581a95a804f77259153c030d39f861282b468612 (diff)
downloadrust-3f6e8ffe64b57b0eaba6812208e94500422ca40c.tar.gz
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/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 657109c6df2..d8d9b8d6eb4 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)
 {