Implement _str.len() to return the number of bytes, rename it to byte_len(),

and add a test.
This commit is contained in:
Jeffrey Yasskin
2010-07-25 00:36:03 -07:00
committed by Graydon Hoare
parent 581a95a804
commit 3f6e8ffe64
4 changed files with 33 additions and 5 deletions

View File

@@ -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)
{